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

Definition

Ruft den Wochentag ab, der durch diese Instanz dargestellt wird.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

Eigenschaftswert

Eine Enumerationskonstante, die den Wochentag dieses DateTime-Werts angibt.An enumerated constant that indicates the day of the week of this DateTime value.

Beispiele

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

Hinweise

Der Wert der Konstanten in der DayOfWeek -Enumeration reicht von DayOfWeek.Sunday bis. DayOfWeek.SaturdayThe value of the constants in the DayOfWeek enumeration ranges from DayOfWeek.Sunday to DayOfWeek.Saturday. Wenn Sie in eine ganze Zahl umgewandelt wird, reicht der Wert von 0 DayOfWeek.Sunday(null) bis 6 DayOfWeek.Saturday(was angibt).If cast to an integer, its value ranges from zero (which indicates DayOfWeek.Sunday) to six (which indicates DayOfWeek.Saturday).

Die DayOfWeek -Eigenschaft gibt eine Enumerationskonstante zurück, die die Regions-und Spracheinstellungen eines Systems nicht widerspiegelt.The DayOfWeek property returns an enumerated constant; it does not reflect a system's regional and language settings. Um eine Zeichenfolge abzurufen, die einen lokalisierten Wochentagsnamen für ein bestimmtes Datum darstellt, rufen Sie ToString eine der über Ladungen format der Methode auf, die einen ddd - dddd Parameter enthält, und übergeben Sie entweder die benutzerdefinierten Format Zeichenfolgen oder.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. Weitere Informationen finden Sie unter Vorgehensweise: Extrahieren des Wochentags aus einem bestimmten Datum.For details, see How to: Extract the Day of the Week from a Specific Date.

Gilt für:

Siehe auch