System.DayOfWeek Enum
The System.DayOfWeek
enumeration represents the days of the week.
Namespace
Assembly
System.Runtime.dll
Members
Name | Value | Description |
---|---|---|
Sunday | 0 | Represents Sunday. |
Monday | 1 | Represents Monday. |
Tuesday | 2 | Represents Tuesday. |
Wednesday | 3 | Represents Wednesday. |
Thursday | 4 | Represents Thursday. |
Friday | 5 | Represents Friday. |
Saturday | 6 | Represents Saturday. |
Example
// Print all days of the week
foreach (System.DayOfWeek day in System.Enum.GetValues(typeof(System.DayOfWeek)))
{
Console.WriteLine($"{(int)day} - {day}");
}
// Convert numeric input to DayOfWeek
int userInput = 3;
System.DayOfWeek result = (System.DayOfWeek)userInput;
Console.WriteLine($"The day for value {userInput} is {result}.");