通过


DateAndTime.MonthName(Int32, Boolean) 方法

定义

返回一个字符串值,该值包含指定月份的名称。

public static string MonthName(int Month, bool Abbreviate = false);
static member MonthName : int * bool -> string
Public Function MonthName (Month As Integer, Optional Abbreviate As Boolean = false) As String

参数

Month
Int32

必填。 月份的数字指定,从 1 到 13;1 表示 1 月和 12 日表示 12 月。 可以将值 13 与 13 个月的日历一起使用。 如果系统使用的是 12 个月日历且 Month 为 13, MonthName 则返回一个空字符串。

Abbreviate
Boolean

可选。 True 若要缩写月份名称,则为 ;否则,为 False. 默认值为 False

返回

包含指定月份的名称的字符串值。

例外

Month 小于 1 或大于 13。

示例

此示例使用 MonthName 函数根据给定的整数来确定月份的名称。 布尔值将确定是否显示全名(False)或缩写名称(True)。

Dim thisMonth As Integer
Dim name As String
thisMonth = 4
' Set Abbreviate to True to return an abbreviated name.
name = MonthName(thisMonth, True)
' name now contains "Apr".

注解

返回的MonthName字符串不仅取决于输入参数,还取决于 Windows 控制面板中指定的区域选项设置。

注释

MonthName使用命名空间中类的属性CultureInfo中的System.Globalization当前日历设置CurrentCulture。 默认值 CurrentCulture控制面板 设置确定。

适用于

另请参阅