DayOfWeek 枚举

指定一周的某天。

**命名空间:**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

成员

  成员名称 说明
由 .NET Compact Framework 支持 Friday 表示星期五。 
由 .NET Compact Framework 支持 Monday 表示星期一。 
由 .NET Compact Framework 支持 Saturday 表示星期六。 
由 .NET Compact Framework 支持 Sunday 表示星期日。 
由 .NET Compact Framework 支持 Thursday 表示星期四。 
由 .NET Compact Framework 支持 Tuesday 表示星期二。 
由 .NET Compact Framework 支持 Wednesday 表示星期三。 

备注

在每周有七天的日历中,DayOfWeek 枚举表示一周中的某天。该枚举的范围从零(表示星期日)到六(表示星期六)。

当最好是对一周的某天进行强类型指定时,该枚举很有用。例如,该枚举是 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

请参见

参考

System 命名空间