Export (0) Print
Expand All
Expand Minimize
4 out of 10 rated this helpful - Rate this topic

DayOfWeek Enumeration

Specifies the day of the week.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum DayOfWeek
Member nameDescription
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsFridayIndicates Friday.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsMondayIndicates Monday.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsSaturdayIndicates Saturday.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsSundayIndicates Sunday.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsThursdayIndicates Thursday.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsTuesdayIndicates Tuesday.
Supported by the XNA FrameworkSupported by Portable Class LibrarySupported in .NET for Windows Store appsWednesdayIndicates Wednesday.

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 
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.
*/

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft. All rights reserved.