C# DateTime Day

Description

DateTime Day gets the day of the month represented by this instance.

Syntax

DateTime.Day has the following syntax.


public int Day { get; }

Example

Gets the day of the month represented by this instance.


using System;//from   w  w  w . jav  a2s . com
public class MainClass{
  public static void Main(String[] argv){  
    // Return day of 1/13/2009.
    DateTime dateGregorian = new DateTime(2009, 1, 13);
    System.Console.WriteLine(dateGregorian.Day);              
    // Displays 13 (Gregorian day). 

  }
}

The code above generates the following result.

Example 2

Example Day value from HijriCalendar


using System;/*from  ww w.j a  v  a 2s  .c  om*/
using System.Globalization;
public class MainClass{
  public static void Main(String[] argv){  

    HijriCalendar hijri = new HijriCalendar();
    DateTime dateHijri = new DateTime(1430, 1, 17, hijri);

    System.Console.WriteLine(dateHijri.Day);                    


    System.Console.WriteLine(hijri.GetDayOfMonth(dateHijri));   
    
    
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version