C# DateTime DayOfWeek

Description

DateTime DayOfWeek gets the day of the week represented by this instance.

Syntax

DateTime.DayOfWeek has the following syntax.


public DayOfWeek DayOfWeek { get; }

Example

The following example demonstrates the DayOfWeek property and the System.DayOfWeek enumeration.


using System;/*  w  w w  .  ja v  a  2  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 »
    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