Sdílet prostřednictvím


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

Name Hodnota Description
Sunday 0

Označuje neděli.

Monday 1

Označuje pondělí.

Tuesday 2

Označuje úterý.

Wednesday 3

Označuje středu.

Thursday 4

Označuje čtvrtek.

Friday 5

Označuje pátek.

Saturday 6

Označuje sobotu.

Příklady

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

// 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. Při přetypování na celé číslo se jeho hodnota pohybuje od nuly (což označuje neděli) do šesti (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 typ hodnoty vlastnosti pro vlastnost DateTime.DayOfWeek a DateTimeOffset.DayOfWeek vlastnosti.

Členy výčtu DayOfWeek nejsou lokalizovány. Pokud chcete vrátit lokalizovaný název dne v týdnu, zavolejte DateTime.ToString(String) metodu DateTime.ToString(String, IFormatProvider) nebo řetězec formátu "ddd" nebo "dddd". První formátovací řetězec vytvoří zkrácený název dne v týdnu; výsledkem je celý název dne v týdnu.

Platí pro