DateTimeOffset.DayOfWeek 속성

정의

현재 DateTimeOffset 개체가 나타내는 요일을 가져옵니다.Gets the day of the week represented by the current DateTimeOffset object.

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

속성 값

현재 DateTimeOffset 개체의 요일을 나타내는 열거형 값 중 하나입니다.One of the enumeration values that indicates the day of the week of the current DateTimeOffset object.

예제

다음 예제에서는 2008 년의 각 월의 첫 번째 일의 요일 이름을 표시합니다.The following example displays the weekday name of the first day of each month of the year 2008.

DateTimeOffset startOfMonth = new DateTimeOffset(2008, 1, 1, 0, 0, 0, 
                                         DateTimeOffset.Now.Offset);
int year = startOfMonth.Year;
do 
{
   Console.WriteLine("{0:MMM d, yyyy} is a {1}.", startOfMonth, startOfMonth.DayOfWeek);
   startOfMonth = startOfMonth.AddMonths(1);
}
while (startOfMonth.Year == year);
// This example writes the following output to the console:
//    Jan 1, 2008 is a Tuesday.
//    Feb 1, 2008 is a Friday.
//    Mar 1, 2008 is a Saturday.
//    Apr 1, 2008 is a Tuesday.
//    May 1, 2008 is a Thursday.
//    Jun 1, 2008 is a Sunday.
//    Jul 1, 2008 is a Tuesday.
//    Aug 1, 2008 is a Friday.
//    Sep 1, 2008 is a Monday.
//    Oct 1, 2008 is a Wednesday.
//    Nov 1, 2008 is a Saturday.
//    Dec 1, 2008 is a Monday.      
Dim startOfMonth As New DateTimeOffset(#1/1/2008#, _
                                      DateTimeOffset.Now.Offset)
Dim year As Integer = startOfMonth.Year
Do While startOfMonth.Year = year
   Console.WriteLine("{0:MMM d, yyyy} is a {1}.", _
                     startOfMonth, startOfMonth.DayOfWeek)
   startOfMonth = startOfMonth.AddMonths(1)                   
Loop      
' This example writes the following output to the console:
'    Jan 1, 2008 is a Tuesday.
'    Feb 1, 2008 is a Friday.
'    Mar 1, 2008 is a Saturday.
'    Apr 1, 2008 is a Tuesday.
'    May 1, 2008 is a Thursday.
'    Jun 1, 2008 is a Sunday.
'    Jul 1, 2008 is a Tuesday.
'    Aug 1, 2008 is a Friday.
'    Sep 1, 2008 is a Monday.
'    Oct 1, 2008 is a Wednesday.
'    Nov 1, 2008 is a Saturday.
'    Dec 1, 2008 is a Monday.      

설명

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).

또한 "D" 서식 지정자 또는 "dddd" 사용자 지정 형식 지정자를 사용 하 여 특정 날짜의 요일 이름을 표시할 수 있습니다.You can also display the weekday name of a particular date by using the "D" format specifier or the "dddd" custom format specifier. 예를 들면 다음과 같습니다.For example:

DateTimeOffset displayDate = new DateTimeOffset(2008, 1, 1, 13, 18, 00, 
                                                DateTimeOffset.Now.Offset);
Console.WriteLine("{0:D}", displayDate);  // Output: Tuesday, January 01, 2008                     
Console.WriteLine("{0:d} is a {0:dddd}.", 
                  displayDate);           // Output: 1/1/2008 is a Tuesday.
Dim displayDate As New DateTimeOffset(#1/1/2008 1:18PM#, _
                                      DateTimeOffset.Now.Offset)
Console.WriteLine("{0:D}", displayDate)    ' Output: Tuesday, January 01, 2008                     
Console.WriteLine("{0:d} is a {0:dddd}.", _
                  displayDate)             ' Output: 1/1/2008 is a Tuesday.

이 속성에서 반환 하는 DayOfWeek 열거형 멤버의 ToString 메서드를 호출 하 여 반환 되는 문자열은 지역화 되지 않습니다.Note that the string returned by calling the ToString method of the DayOfWeek enumeration member that is returned by this property is not localized. 현재 문화권 또는 특정 문화권의 요일 이름이 포함 된 문자열을 추출 하려면 "dddd" 사용자 지정 형식 지정자를 사용 하 여 ToString 메서드를 호출 합니다.To extract a string that contains the weekday name of the current culture or of a specific culture, call the ToString method with the "dddd" custom format specifier. 예를 들어 다음 코드는 fr-fr 문화권을 사용 하 여 날짜의 요일 이름을 표시 합니다.For example, the following code displays the weekday name for a date using the fr-fr culture.

DateTimeOffset thisDate = new DateTimeOffset(2007, 6, 1, 6, 15, 0, 
                                             DateTimeOffset.Now.Offset);
string weekdayName = thisDate.ToString("dddd", 
                                       new CultureInfo("fr-fr")); 
Console.WriteLine(weekdayName);                  // Displays vendredi     
Dim thisDate As New DateTimeOffset(#6/1/2007 6:15AM#, _
                                      DateTimeOffset.Now.Offset)
Dim weekdayName As String = thisDate.ToString("dddd", _
                            New CultureInfo("fr-fr")) 
Console.WriteLine(weekdayName)                        ' Displays vendredi     

적용 대상