DateTime.Month 属性

获取此实例所表示日期的月份部分。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public ReadOnly Property Month As Integer
用法
Dim instance As DateTime
Dim value As Integer

value = instance.Month
public int Month { get; }
public:
property int Month {
    int get ();
}
/** @property */
public int get_Month ()
public function get Month () : int

属性值

月组成部分,表示为 1 和 12 之间的一个值。

示例

下面的代码示例演示了 Month 属性。

Dim moment As New System.DateTime(1999, 1, 13, 3, 57, 32, 11)

' Year gets 1999.
Dim year As Integer = moment.Year

' Month gets 1 (January).
Dim month As Integer = moment.Month

' Day gets 13.
Dim day As Integer = moment.Day

' Hour gets 3.
Dim hour As Integer = moment.Hour

' Minute gets 57.
Dim minute As Integer = moment.Minute

' Second gets 32.
Dim second As Integer = moment.Second

' Millisecond gets 11.
Dim millisecond As Integer = moment.Millisecond
System.DateTime moment = new System.DateTime(
                                1999, 1, 13, 3, 57, 32, 11);
// Year gets 1999.
int year = moment.Year;

// Month gets 1 (January).
int month = moment.Month;

// Day gets 13.
int day = moment.Day;

// Hour gets 3.
int hour = moment.Hour;

// Minute gets 57.
int minute = moment.Minute;

// Second gets 32.
int second = moment.Second;

// Millisecond gets 11.
int millisecond = moment.Millisecond;
System::DateTime moment = System::DateTime(
   1999, 1, 13, 3, 57, 32, 11 );

// Year gets 1999.
int year = moment.Year;

// Month gets 1 (January).
int month = moment.Month;

// Day gets 13.
int day = moment.Day;

// Hour gets 3.
int hour = moment.Hour;

// Minute gets 57.
int minute = moment.Minute;

// Second gets 32.
int second = moment.Second;

// Millisecond gets 11.
int millisecond = moment.Millisecond;
System.DateTime moment = new System.DateTime(1999, 1, 13,
                        3, 57, 32, 11);

// Year gets 1999.
int year = moment.get_Year();

// Month gets 1 (January).
int month = moment.get_Month();

// Day gets 13.
int day = moment.get_Day();

// Hour gets 3.
int hour = moment.get_Hour();

// Minute gets 57.
int minute = moment.get_Minute();

// Second gets 32.
int second = moment.get_Second();

// Millisecond gets 11.
int millisecond = moment.get_Millisecond();

平台

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

请参见

参考

DateTime 结构
DateTime 成员
System 命名空间