/// <summary>
/// 返回月份拥有的天数
/// </summary>
/// <param name="month"></param>
/// <param name="year"></param>
/// <returns></returns>
public static int GetLastDay(int month, int year)
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 2:
return year % 100 != 0 && year % 4 == 0 || year % 400 == 0 ? 29 : 28;
case 4:
case 6:
case 9:
case 11:
return 30;
}
return -1;
}
/// 返回月份拥有的天数
/// </summary>
/// <param name="month"></param>
/// <param name="year"></param>
/// <returns></returns>
public static int GetLastDay(int month, int year)
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 2:
return year % 100 != 0 && year % 4 == 0 || year % 400 == 0 ? 29 : 28;
case 4:
case 6:
case 9:
case 11:
return 30;
}
return -1;
}
本文转自火地晋博客园博客,原文链接:http://www.cnblogs.com/yelaiju/archive/2010/09/02/1815771.html,如需转载请自行联系原作者