System.DayOfWeek Enum

Represents the day of the week.

Namespace: System
Type: Enum

Members

Remarks

The DayOfWeek enumeration provides a convenient way to represent the days of the week. Its members are constants that represent each day, starting with Sunday as the first day (value 0) and ending with Saturday (value 6).

This enumeration is commonly used with the DateTime struct to determine or set the day of the week for a particular date.

Examples

using System;

public class Example
{
    public static void Main()
    {
        DateTime today = DateTime.Today;
        Console.WriteLine($"Today is {today.DayOfWeek}.");

        if (today.DayOfWeek == DayOfWeek.Saturday || today.DayOfWeek == DayOfWeek.Sunday)
        {
            Console.WriteLine("It's the weekend!");
        }
        else
        {
            Console.WriteLine("It's a weekday.");
        }
    }
}