DayOfWeek Enumeration
Specifies the day of the week.
Assembly: mscorlib (in mscorlib.dll)
The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. The value of the constants in this enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. If cast to an integer, its value ranges from zero (which indicates DayOfWeek.Sunday) to six (which indicates DayOfWeek.Saturday).
This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. For example, this enumeration is the type of the property value for the DateTime.DayOfWeek property.
The members of the DayOfWeek enumeration are not localized. To return the localized name of the day of the week, call the DateTime.ToString(String) or the DateTime.ToString(String, IFormatProvider) method with either the "ddd" or "dddd" format strings. The former format string produces the abbreviated weekday name; the latter produces the full weekday name.
The following example demonstrates the DateTime.DayOfWeek property and the DayOfWeek enumeration.
' This example demonstrates the DateTime.DayOfWeek property Imports System Class Sample Public Shared Sub Main() ' Assume the current culture is en-US. ' Create a DateTime for the first of May, 2003. Dim dt As New DateTime(2003, 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) End Sub 'Main End Class 'Sample ' 'This example produces the following results: ' 'Is Thursday the day of the week for 5/1/2003?: True 'The day of the week for 5/1/2003 is Thursday. '
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
