DayOfWeek 列挙型

定義

曜日を指定します。Specifies the day of the week.

public enum class DayOfWeek
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum DayOfWeek
type DayOfWeek = 
Public Enum DayOfWeek
継承
DayOfWeek
属性

フィールド

Friday 5

金曜日を示します。Indicates Friday.

Monday 1

月曜日を示します。Indicates Monday.

Saturday 6

土曜日を示します。Indicates Saturday.

Sunday 0

日曜日を示します。Indicates Sunday.

Thursday 4

木曜日を示します。Indicates Thursday.

Tuesday 2

火曜日を示します。Indicates Tuesday.

Wednesday 3

水曜日を示します。Indicates Wednesday.

DateTime.DayOfWeek プロパティDayOfWeekと列挙体の例を次に示します。The following example demonstrates the DateTime.DayOfWeek property and the 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は、週の7日間のカレンダーの曜日を表します。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 Sunday to Saturday. 整数にキャストする場合、値は 0 (日曜日を示す) から 6 (土曜日を示す) までの範囲内で指定します。If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday).

この列挙体は、曜日の厳密に型指定された指定を行うことが望ましい場合に便利です。This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. たとえば、この列挙体は、プロパティDateTime.DayOfWeekDateTimeOffset.DayOfWeekプロパティのプロパティ値の型です。For example, this enumeration is the type of the property value for the DateTime.DayOfWeek and DateTimeOffset.DayOfWeek properties.

DayOfWeek列挙体のメンバーはローカライズされていません。The members of the DayOfWeek enumeration are not localized. 曜日のローカライズされた名前を取得するにDateTime.ToString(String) DateTime.ToString(String, IFormatProvider)は、"ddd" または "dddd" のいずれかの書式指定文字列を使用して、メソッドまたはメソッドを呼び出します。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.

適用対象