本文整理汇总了C#中Month.Number方法的典型用法代码示例。如果您正苦于以下问题:C# Month.Number方法的具体用法?C# Month.Number怎么用?C# Month.Number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Month
的用法示例。
在下文中一共展示了Month.Number方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LocalDate
/// <summary>
/// Creates a new LocalDate with the given year, month and day.
/// </summary>
/// <param name="year"></param>
/// <param name="month"></param>
/// <param name="day"></param>
public LocalDate(int year, Month month, int day)
{
int monthNumber = month.Number();
if (monthNumber < 1 || monthNumber > 12)
{
throw new ArgumentOutOfRangeException("month", "invalid month with number " + ((int)month));
}
if (day < 1)
{
throw new ArgumentOutOfRangeException("day", "day must be at least 1");
}
int monthLength = month.Length(DateTime.IsLeapYear(year));
if (day > monthLength)
{
throw new ArgumentOutOfRangeException("day", month.Name() + " " + year + " has only " + monthLength + " days");
}
m_year = year;
m_month = month;
m_day = day;
}
示例2: FormatMonth
private static string FormatMonth(Month month, string format, CultureInfo culture)
{
// use an arbitrary DateTime in the given month and format it only with the full name of the month
DateTime dateTime = new DateTime(2016, month.Number(), 1);
return dateTime.ToString(format, culture);
}