指定一週中的星期名稱。
命名空間: System
組件: mscorlib (在 mscorlib.dll 中)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration DayOfWeek
Dim instance As DayOfWeek
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum DayOfWeek
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum class DayOfWeek
/** @attribute SerializableAttribute() */
/** @attribute ComVisibleAttribute(true) */
public enum DayOfWeek
SerializableAttribute
ComVisibleAttribute(true)
public enum DayOfWeek
| | 成員名稱 | 說明 |
|---|
.gif) | Friday | 表示星期五。 |
.gif) | Monday | 表示星期一。 |
.gif) | Saturday | 表示星期六。 |
.gif) | Sunday | 表示星期天。 |
.gif) | Thursday | 表示星期四。 |
.gif) | Tuesday | 表示星期二。 |
.gif) | Wednesday | 表示星期三。 |
DayOfWeek 列舉型別 (Enumeration) 表示在日曆中一週的星期名稱,每週有七天。這個列舉型別的範圍從零開始 (指示星期天) 到六 (表示星期六)。
這個列舉型別在您想要擁有強型別 (Strongly Typed) 規格的星期名稱時,會非常有用。例如,這個列舉型別為 DateTime.DayOfWeek 屬性的屬性值型別。
下列範例說明了 DateTime.DayOfWeek 屬性和 DayOfWeek 列舉型別。
' This example demonstrates the DateTime.DayOfWeek property
Imports System
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.
'
// 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
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
import System.*;
class Sample
{
public static void main(String[] args)
{
// 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, (System.Boolean)(dt.get_DayOfWeek() == DayOfWeek.Thursday));
Console.WriteLine("The day of the week for {0:d} is {1}.", dt,
dt.get_DayOfWeek());
} //main
} //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.
*/
Windows 98、 Windows 2000 SP4、 Windows CE、 Windows Millennium Edition、 Windows Mobile for Pocket PC、 Windows Mobile for Smartphone、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
.NET Framework
支援版本:2.0、1.1、1.0
.NET Compact Framework
支援版本:2.0、1.0