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
Imports System

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 'Main
End Class 'Sample
'
'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. 特定の日付のローカライズされた曜日名を表す文字列を取得する呼び出しのオーバー ロードの 1 つ、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.

適用対象

こちらもご覧ください