DayOfWeek Enumeração

Definição

Especifica o dia da semana.

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
Herança
DayOfWeek
Atributos

Campos

Friday 5

Indica sexta-feira.

Monday 1

Indica segunda-feira.

Saturday 6

Indica sábado.

Sunday 0

Indica domingo.

Thursday 4

Indica quinta-feira.

Tuesday 2

Indica terça-feira.

Wednesday 3

Indica quarta-feira.

Exemplos

O exemplo a seguir demonstra a DateTime.DayOfWeek propriedade e a DayOfWeek enumeração .

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

Comentários

A DayOfWeek enumeração representa o dia da semana em calendários que têm sete dias por semana. O valor das constantes nesta enumeração varia de domingo a sábado. Se convertido em um inteiro, seu valor varia de zero (o que indica domingo) a seis (o que indica sábado).

Essa enumeração é útil quando é desejável ter uma especificação fortemente tipada do dia da semana. Por exemplo, essa enumeração é o tipo do valor da propriedade para as DateTime.DayOfWeek propriedades e DateTimeOffset.DayOfWeek .

Os membros da DayOfWeek enumeração não são localizados. Para retornar o nome localizado do dia da semana, chame o DateTime.ToString(String) método ou DateTime.ToString(String, IFormatProvider) com as cadeias de caracteres de formato "ddd" ou "dddd". A cadeia de caracteres de formato anterior produz o nome abreviado do dia da semana; este último produz o nome completo do dia da semana.

Aplica-se a