DayOfWeek Výčet

Definice

Určuje den v týdnu.

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
Dědičnost
DayOfWeek
Atributy

Pole

Friday 5

Označuje pátek.

Monday 1

Označuje pondělí.

Saturday 6

Označuje sobotu.

Sunday 0

Označuje neděli.

Thursday 4

Označuje čtvrtek.

Tuesday 2

Označuje úterý.

Wednesday 3

Označuje středu.

Příklady

Následující příklad ukazuje DateTime.DayOfWeek vlastnost a DayOfWeek výčet.

// 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.
'

Poznámky

Výčet DayOfWeek představuje den v týdnu v kalendářích, které mají sedm dní v týdnu. Hodnota konstant v tomto výčtu se pohybuje od neděle do soboty. Pokud je přetypování na celé číslo, jeho hodnota se pohybuje od nuly (která označuje neděli) na šest (což označuje sobotu).

Tento výčet je užitečný, pokud je žádoucí mít specifikaci dne v týdnu silného typu. Tento výčet je například typem hodnoty vlastnosti pro vlastnost DateTime.DayOfWeek a DateTimeOffset.DayOfWeek vlastnosti.

Členové výčtu DayOfWeek nejsou lokalizováni. Chcete-li vrátit lokalizovaný název dne v týdnu, zavolejte DateTime.ToString(String) metodu DateTime.ToString(String, IFormatProvider) s řetězci formátu "ddd" nebo "dddd". První formátovací řetězec vytvoří zkrácený název dne v týdnu; druhá vytvoří celý název dne v týdnu.

Platí pro