DateTime.DayOfWeek Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bu örnek tarafından temsil edilen haftanın gününü alır.
public:
property DayOfWeek DayOfWeek { DayOfWeek get(); };
public DayOfWeek DayOfWeek { get; }
member this.DayOfWeek : DayOfWeek
Public ReadOnly Property DayOfWeek As DayOfWeek
Özellik Değeri
Bu DateTime değerin haftanın gününü gösteren numaralandırılmış sabit.
Örnekler
Aşağıdaki örnekte DayOfWeek özelliği ve numaralandırma gösterilmektedir System.DayOfWeek .
// 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
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.
'
Açıklamalar
Sabit listesi içindeki DayOfWeek sabitlerin değeri ile DayOfWeek.SundayDayOfWeek.Saturdayarasında değişir. Bir tamsayıya dönüştürülürse, değeri sıfırdan (gösterir DayOfWeek.Sunday) altıya (gösterir DayOfWeek.Saturday) kadar değişir.
DayOfWeek özelliği numaralandırılmış bir sabit döndürür; sistemin bölgesel ve dil ayarlarını yansıtmaz. Belirli bir tarih için yerelleştirilmiş hafta içi adını temsil eden bir dizeyi almak için, parametre içeren yöntemin ToString aşırı yüklemelerinden birini çağırın ve bunu ddd veya dddd özel biçim dizelerini format geçirin. Ayrıntılar için bkz . Nasıl yapılır: Belirli bir Tarihten Haftanın Gününü Ayıklama.