DayOfWeek DayOfWeek DayOfWeek DayOfWeek Enum

定義

曜日を指定します。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
継承
属性

フィールド

Friday Friday Friday Friday 5

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

Monday Monday Monday Monday 1

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

Saturday Saturday Saturday Saturday 6

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

Sunday Sunday Sunday Sunday 0

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

Thursday Thursday Thursday Thursday 4

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

Tuesday Tuesday Tuesday Tuesday 2

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

Wednesday Wednesday Wednesday 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
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列挙体は、週 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.DayOfWeekプロパティ。For example, this enumeration is the type of the property value for the DateTime.DayOfWeek property.

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

適用対象