DayOfWeek DayOfWeek DayOfWeek DayOfWeek Enum

Definizione

Specifica il giorno della settimana.Specifies the day of the week.

public enum class DayOfWeek
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum DayOfWeek
type DayOfWeek = 
Public Enum DayOfWeek
Ereditarietà
Attributi

Campi

Friday Friday Friday Friday 5

Indica il venerdì.Indicates Friday.

Monday Monday Monday Monday 1

Indica il lunedì.Indicates Monday.

Saturday Saturday Saturday Saturday 6

Indica il sabato.Indicates Saturday.

Sunday Sunday Sunday Sunday 0

Indica la domenica.Indicates Sunday.

Thursday Thursday Thursday Thursday 4

Indica il giovedì.Indicates Thursday.

Tuesday Tuesday Tuesday Tuesday 2

Indica il martedì.Indicates Tuesday.

Wednesday Wednesday Wednesday Wednesday 3

Indica il mercoledì.Indicates Wednesday.

Esempi

Nell'esempio seguente vengono illustrati la DateTime.DayOfWeek proprietà e l' DayOfWeek enumerazione.The following example demonstrates the DateTime.DayOfWeek property and the DayOfWeek enumeration.

// 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
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 'Main
End Class 'Sample
'
'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' DayOfWeek enumerazione rappresenta il giorno della settimana nei calendari con sette giorni alla settimana.The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. Il valore delle costanti in questa enumerazione è compreso tra domenica e sabato.The value of the constants in this enumeration ranges from Sunday to Saturday. Se viene eseguito il cast su un numero intero, il relativo valore è compreso tra zero, che indica domenica, a sei, che indica sabato.If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday).

Questa enumerazione è utile quando è consigliabile avere una specifica fortemente tipizzata del giorno della settimana.This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. Questa enumerazione, ad esempio, è il tipo del valore della proprietà per DateTime.DayOfWeek le DateTimeOffset.DayOfWeek proprietà e.For example, this enumeration is the type of the property value for the DateTime.DayOfWeek and DateTimeOffset.DayOfWeek properties.

I membri dell' DayOfWeek enumerazione non sono localizzati.The members of the DayOfWeek enumeration are not localized. 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".To return the localized name of the day of the week, call the DateTime.ToString(String) or the DateTime.ToString(String, IFormatProvider) method with either the "ddd" or "dddd" format strings. La stringa di formato precedente produce il nome del giorno della settimana abbreviato; il secondo produce il nome del giorno della settimana completo.The former format string produces the abbreviated weekday name; the latter produces the full weekday name.

Si applica a