本文整理汇总了C#中Month.Length方法的典型用法代码示例。如果您正苦于以下问题:C# Month.Length方法的具体用法?C# Month.Length怎么用?C# Month.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Month
的用法示例。
在下文中一共展示了Month.Length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}