DateTime.DayOfWeek DateTime.DayOfWeek DateTime.DayOfWeek DateTime.DayOfWeek Property

Definición

Obtiene el día de la semana representado por esta instancia.Gets the day of the week represented by this instance.

public:
 property DayOfWeek DayOfWeek { DayOfWeek get(); };
public DayOfWeek DayOfWeek { get; }
member this.DayOfWeek : DayOfWeek
Public ReadOnly Property DayOfWeek As DayOfWeek

Valor de propiedad

Constante enumerada que indica el día de la semana de este valor DateTime.An enumerated constant that indicates the day of the week of this DateTime value.

Ejemplos

En el ejemplo siguiente se DayOfWeek muestra la propiedad System.DayOfWeek y la enumeración.The following example demonstrates the DayOfWeek property and the System.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
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.
'

Comentarios

El valor de las constantes de la DayOfWeek enumeración va de DayOfWeek.Sunday a. DayOfWeek.SaturdayThe value of the constants in the DayOfWeek enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. Si se convierte en un entero, su valor va de cero (que indica DayOfWeek.Sunday) a seis (que indica DayOfWeek.Saturday).If cast to an integer, its value ranges from zero (which indicates DayOfWeek.Sunday) to six (which indicates DayOfWeek.Saturday).

La DayOfWeek propiedad devuelve una constante enumerada; no refleja la configuración regional y de idioma de un sistema.The DayOfWeek property returns an enumerated constant; it does not reflect a system's regional and language settings. Para recuperar una cadena que representa un nombre localizado del día de la semana para una fecha determinada, llame a una de las ToString sobrecargas del format método que incluye un parámetro y ddd pásele dddd las cadenas de formato personalizado o.To retrieve a string representing a localized weekday name for a particular date, call one of the overloads of the ToString method that includes a format parameter and pass it either the ddd or dddd custom format strings. Para obtener más detalles, vea Cómo: Extraer el día de la semana de una fecha concreta.For details, see How to: Extract the Day of the Week from a Specific Date.

Se aplica a

Consulte también: