DayOfWeek 列挙型

定義

曜日を指定します。

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

フィールド

Friday 5

金曜日を示します。

Monday 1

月曜日を示します。

Saturday 6

土曜日を示します。

Sunday 0

日曜日を示します。

Thursday 4

木曜日を示します。

Tuesday 2

火曜日を示します。

Wednesday 3

水曜日を示します。

次の例では、 DateTime.DayOfWeek プロパティと 列挙体を DayOfWeek 示します。

// 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
open System

// Assume the current culture is en-US.
// Create a DateTime for the first of May, 2003.
let dt = DateTime(2003, 5, 1)
printfn $"Is Thursday the day of the week for {dt:d}?: {dt.DayOfWeek = DayOfWeek.Thursday}"
printfn $"The day of the week for {dt:d} is {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 、1 週間に 7 日の予定表の曜日を表します。 この列挙体の定数の値は、日曜日から土曜日までの範囲です。 整数にキャストすると、その値の範囲は 0 (日曜日を示します) から 6 (土曜日を示します) になります。

この列挙は、曜日を厳密に型指定することが望ましい場合に便利です。 たとえば、この列挙体は、 プロパティと DateTimeOffset.DayOfWeek プロパティのプロパティ値のDateTime.DayOfWeek型です。

列挙体の DayOfWeek メンバーはローカライズされません。 曜日のローカライズされた名前を返すには、"ddd" または DateTime.ToString(String, IFormatProvider) "dddd" 書式指定文字列を使用して または メソッドを呼び出DateTime.ToString(String)します。 前の書式指定文字列は、省略された曜日名を生成します。後者は完全な曜日名を生成します。

適用対象