DateTime.DayOfWeek Property

Definition

이 인스턴스가 나타내는 주의 일 수를 가져옵니다.Gets the day of the week represented by this instance.

public:
 property DayOfWeek DayOfWeek { DayOfWeek get(); };
public DayOfWeek DayOfWeek { get; }
member this.DayOfWeek : DayOfWeek
Public ReadOnly Property DayOfWeek As DayOfWeek

Property Value

DayOfWeek

DateTime 값의 요일을 나타내는 열거형 상수입니다.An enumerated constant that indicates the day of the week of this DateTime value.

Examples

다음 예제에서는 DayOfWeek 속성과 System.DayOfWeek 열거형을 보여 줍니다.The following example demonstrates the DayOfWeek property and the System.DayOfWeek enumeration.

// This example demonstrates the DateTime.DayOfWeek property
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}", 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.
*/
// 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.
*/
' This example demonstrates the DateTime.DayOfWeek property
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
End Class
'
'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.
'

Remarks

DayOfWeek 열거형의 상수 값은 DayOfWeek.Sunday부터 DayOfWeek.Saturday까지의 범위에 있습니다.The value of the constants in the DayOfWeek enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. 정수로 캐스팅 하는 경우 해당 값의 범위는 0 (DayOfWeek.Sunday를 나타냄)에서 6 (DayOfWeek.Saturday를 나타냄) 사이입니다.If cast to an integer, its value ranges from zero (which indicates DayOfWeek.Sunday) to six (which indicates DayOfWeek.Saturday).

DayOfWeek 속성은 열거형 상수를 반환 합니다. 시스템의 국가 및 언어 설정이 반영 되지 않습니다.The DayOfWeek property returns an enumerated constant; it does not reflect a system's regional and language settings. 특정 날짜에 대 한 지역화 된 요일 이름을 나타내는 문자열을 검색 하려면 format 매개 변수를 포함 하는 ToString 메서드의 오버 로드 중 하나를 호출 하 고 ddd 또는 dddd 사용자 지정 형식 문자열을 전달 합니다.To retrieve a string representing a localized weekday name for a particular date, call one of the overloads of the ToString method that includes a format parameter and pass it either the ddd or dddd custom format strings. 자세한 내용은 방법: 특정 날짜의 요일 추출을 참조 하세요.For details, see How to: Extract the Day of the Week from a Specific Date.

Applies to

See also