DayOfWeek Wyliczenie

Definicja

Określa dzień tygodnia.

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
Dziedziczenie
DayOfWeek
Atrybuty

Pola

Friday 5

Wskazuje piątek.

Monday 1

Wskazuje poniedziałek.

Saturday 6

Wskazuje sobotę.

Sunday 0

Wskazuje niedzielę.

Thursday 4

Wskazuje czwartek.

Tuesday 2

Wskazuje wtorek.

Wednesday 3

Wskazuje środę.

Przykłady

W poniższym przykładzie przedstawiono DateTime.DayOfWeek właściwość i wyliczenie 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.
'

Uwagi

Wyliczenie DayOfWeek reprezentuje dzień tygodnia w kalendarzach, które mają siedem dni w tygodniu. Wartość stałych w tym wyliczenia waha się od niedzieli do soboty. Jeśli rzutowanie do liczby całkowitej, jego wartość waha się od zera (co oznacza niedzielę) do sześciu (co oznacza sobotę).

To wyliczenie jest przydatne, gdy pożądane jest posiadanie silnie typizowanej specyfikacji dnia tygodnia. Na przykład ta wyliczenie jest typem wartości właściwości właściwości DateTime.DayOfWeek i DateTimeOffset.DayOfWeek .

Elementy członkowskie wyliczenia DayOfWeek nie są zlokalizowane. Aby zwrócić zlokalizowaną nazwę dnia tygodnia, wywołaj DateTime.ToString(String) metodę lub DateTime.ToString(String, IFormatProvider) za pomocą ciągów formatu "ddd" lub "dddd". Poprzedni ciąg formatu tworzy skróconą nazwę dnia tygodnia; ten ostatni tworzy pełną nazwę dnia tygodnia.

Dotyczy