DateTime.DayOfWeek DateTime.DayOfWeek DateTime.DayOfWeek DateTime.DayOfWeek Property

정의

이 인스턴스가 나타내는 주의 일 수를 가져옵니다.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

속성 값

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

예제

다음 예제는 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.
'

설명

상수 값을 DayOfWeek 열거형에서 범위 DayOfWeek.SundayDayOfWeek.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. 특정 날짜의 지역화 된 요일 이름을 나타내는 문자열을 검색 하려면 오버 로드 중 하나를 호출 합니다 ToString 메서드를 포함 하는 format 매개 변수 전달 중 하나는 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.

적용 대상

추가 정보