DayOfWeek Enumeration

Definition

Gibt den Wochentag an.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
Vererbung
DayOfWeek
Attribute

Felder

Friday 5

Gibt Freitag an.Indicates Friday.

Monday 1

Gibt Montag an.Indicates Monday.

Saturday 6

Gibt Sonnabend an.Indicates Saturday.

Sunday 0

Gibt Sonntag an.Indicates Sunday.

Thursday 4

Gibt Donnerstag an.Indicates Thursday.

Tuesday 2

Gibt Dienstag an.Indicates Tuesday.

Wednesday 3

Gibt Mittwoch an.Indicates Wednesday.

Beispiele

Im folgenden Beispiel werden die DateTime.DayOfWeek -Eigenschaft und DayOfWeek die-Enumeration veranschaulicht.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
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.
'

Hinweise

Die DayOfWeek -Enumeration stellt den Wochentag in Kalendern dar, die sieben Tage pro Woche haben.The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. Der Wert der Konstanten in dieser Enumeration reicht von Sonntag bis Samstag.The value of the constants in this enumeration ranges from Sunday to Saturday. Wenn Sie in eine ganze Zahl umgewandelt wird, reicht der Wert von NULL (der Sonntag) auf sechs (was den Samstag angibt).If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday).

Diese Enumeration ist nützlich, wenn es wünschenswert ist, eine stark typisierte Spezifikation des Wochentags zu haben.This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. Diese Enumeration ist beispielsweise der Typ des Eigenschafts Werts für die DateTime.DayOfWeek Eigenschaften und. DateTimeOffset.DayOfWeekFor example, this enumeration is the type of the property value for the DateTime.DayOfWeek and DateTimeOffset.DayOfWeek properties.

Die Member der DayOfWeek -Enumeration sind nicht lokalisiert.The members of the DayOfWeek enumeration are not localized. Um den lokalisierten Namen des Wochentags zurückzugeben, müssen Sie die DateTime.ToString(String) -Methode DateTime.ToString(String, IFormatProvider) oder die-Methode mit der Format Zeichenfolge "ddd" oder "dddd" aufzurufen.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. Die vorherige Format Zeichenfolge erzeugt den abgekürzten Wochentagsnamen Letztere erzeugt den vollständigen Wochentagsnamen.The former format string produces the abbreviated weekday name; the latter produces the full weekday name.

Gilt für: