Comparteix a través de


DayOfWeek Enumeración

Definición

Especifica el día de la 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
Herencia
DayOfWeek
Atributos

Campos

Friday 5

Indica viernes.

Monday 1

Indica lunes.

Saturday 6

Indica sábado.

Sunday 0

Indica domingo.

Thursday 4

Indica jueves.

Tuesday 2

Indica martes.

Wednesday 3

Indica miércoles.

Ejemplos

En el ejemplo siguiente se muestra la DateTime.DayOfWeek propiedad y la DayOfWeek enumeración .

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

Comentarios

La DayOfWeek enumeración representa el día de la semana en calendarios que tienen siete días por semana. El valor de las constantes de esta enumeración va de domingo a sábado. Si se convierte en un entero, su valor oscila entre cero (que indica domingo) a seis (lo que indica el sábado).

Esta enumeración es útil cuando es conveniente tener una especificación fuertemente tipada del día de la semana. Por ejemplo, esta enumeración es el tipo del valor de propiedad de las DateTime.DayOfWeek propiedades y DateTimeOffset.DayOfWeek .

Los miembros de la DayOfWeek enumeración no se localizan. Para devolver el nombre localizado del día de la semana, llame al DateTime.ToString(String) método o DateTime.ToString(String, IFormatProvider) con las cadenas de formato "ddd" o "dddd". La cadena de formato anterior genera el nombre abreviado del día de la semana; este último genera el nombre completo del día de la semana.

Se aplica a