Condividi tramite


DayOfWeek Enumerazione

Definizione

Specifica il giorno della settimana.

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
Ereditarietà
DayOfWeek
Attributi

Campi

Nome Valore Descrizione
Sunday 0

Indica la domenica.

Monday 1

Indica il lunedì.

Tuesday 2

Indica martedì.

Wednesday 3

Indica mercoledì.

Thursday 4

Indica giovedì.

Friday 5

Indica il venerdì.

Saturday 6

Indica il sabato.

Esempio

Nell'esempio seguente viene illustrata la DateTime.DayOfWeek proprietà e l'enumerazione DayOfWeek .

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

Commenti

L'enumerazione DayOfWeek rappresenta il giorno della settimana nei calendari con sette giorni alla settimana. Il valore delle costanti in questa enumerazione varia da domenica a sabato. Se viene eseguito il cast a un numero intero, il valore è compreso tra zero (che indica domenica) e sei (che indica sabato).

Questa enumerazione è utile quando è consigliabile avere una specifica fortemente tipizzata del giorno della settimana. Ad esempio, questa enumerazione è il tipo del valore della proprietà per le DateTime.DayOfWeek proprietà e DateTimeOffset.DayOfWeek .

I membri dell'enumerazione DayOfWeek non vengono localizzati. Per restituire il nome localizzato del giorno della settimana, chiamare il DateTime.ToString(String)DateTime.ToString(String, IFormatProvider) metodo o con le stringhe di formato "ddd" o "dddd". La stringa di formato precedente produce il nome abbreviato del giorno della settimana; quest'ultimo produce il nome completo del giorno della settimana.

Si applica a