DayOfWeek DayOfWeek DayOfWeek DayOfWeek Enum

Definición

Indica el día de la semana.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
Herencia
Atributos

Campos

Friday Friday Friday Friday 5

Indica viernes.Indicates Friday.

Monday Monday Monday Monday 1

Indica lunes.Indicates Monday.

Saturday Saturday Saturday Saturday 6

Indica sábado.Indicates Saturday.

Sunday Sunday Sunday Sunday 0

Indica domingo.Indicates Sunday.

Thursday Thursday Thursday Thursday 4

Indica jueves.Indicates Thursday.

Tuesday Tuesday Tuesday Tuesday 2

Indica martes.Indicates Tuesday.

Wednesday Wednesday Wednesday Wednesday 3

Indica miércoles.Indicates Wednesday.

Ejemplos

En el ejemplo siguiente se DateTime.DayOfWeek muestra la propiedad DayOfWeek y la enumeración.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.
'

Comentarios

La DayOfWeek enumeración representa el día de la semana en los calendarios que tienen siete días por semana.The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. El valor de las constantes en esta enumeración va de domingo a sábado.The value of the constants in this enumeration ranges from Sunday to Saturday. Si se convierte en un entero, su valor va de cero (que indica el domingo) a seis (que indica sábado).If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday).

Esta enumeración es útil cuando es conveniente tener una especificación fuertemente tipada del día de la semana.This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. Por ejemplo, esta enumeración es el tipo del valor de propiedad para DateTime.DayOfWeek las DateTimeOffset.DayOfWeek propiedades y.For example, this enumeration is the type of the property value for the DateTime.DayOfWeek and DateTimeOffset.DayOfWeek properties.

Los miembros de la DayOfWeek enumeración no están localizados.The members of the DayOfWeek enumeration are not localized. Para devolver el nombre localizado del día de la semana, llame al DateTime.ToString(String) DateTime.ToString(String, IFormatProvider) método o con las cadenas de 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 cadena de formato anterior genera el nombre abreviado del día de la semana; el último genera el nombre completo del día de la semana.The former format string produces the abbreviated weekday name; the latter produces the full weekday name.

Se aplica a