Get the day of the week represented by DateTime in CSharp

Description

The following code shows how to get the day of the week represented by DateTime.

Example


using System;/*from  w w w .j  a v a2  s.c o m*/

class Sample {
    public static void Main() {
        DateTime dt = new DateTime(2013, 5, 1);
        Console.WriteLine("Is Thursday the day of the week for {0:d}?: {1}", 
                           dt, dt.DayOfWeek == DayOfWeek.Thursday);
        Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var