DayOfWeek Enumeration
Specifies the day of the week.
[Visual Basic] <Serializable> Public Enum DayOfWeek [C#] [Serializable] public enum DayOfWeek [C++] [Serializable] __value public enum DayOfWeek [JScript] public Serializable enum DayOfWeek
Remarks
The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. This enumeration ranges from zero, indicating Sunday, to six, indicating 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.
Members
| Member name | Description |
|---|---|
| Friday Supported by the .NET Compact Framework. | Indicates Friday. |
| Monday Supported by the .NET Compact Framework. | Indicates Monday. |
| Saturday Supported by the .NET Compact Framework. | Indicates Saturday. |
| Sunday Supported by the .NET Compact Framework. | Indicates Sunday. |
| Thursday Supported by the .NET Compact Framework. | Indicates Thursday. |
| Tuesday Supported by the .NET Compact Framework. | Indicates Tuesday. |
| Wednesday Supported by the .NET Compact Framework. | Indicates Wednesday. |
Example
[Visual Basic, C#, C++] The following example demonstrates the DateTime.DayOfWeek property and the DayOfWeek enumeration.
[Visual Basic] ' 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. ' [C#] // This example demonstrates the DateTime.DayOfWeek property using System; class Sample { public static void Main() { // Assume the current culture is en-US. // Create a DateTime for the first of May, 2003. DateTime dt = 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); } } /* 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. */ [C++] // This example demonstrates the DateTime.DayOfWeek property #using <mscorlib.dll> using namespace System; int main() { // Assume the current culture is en-US. // Create a DateTime for the first of May, 2003. DateTime dt = DateTime(2003, 5, 1); Console::WriteLine("Is Thursday the day of the week for {0:d}?: {1}", __box(dt), __box(dt.DayOfWeek == DayOfWeek::Thursday)); Console::WriteLine("The day of the week for {0:d} is {1}.", __box(dt), __box(dt.DayOfWeek)); } /* 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. */
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: Mscorlib (in Mscorlib.dll)