您的位置:首页 > 其它

判断闰年与平年的方法与获取指定月份的天数

2010-12-15 09:36 369 查看
1、判断闰年与平年的方法
int intmonth;
if(System.DateTime.IsLeapYear(System.DateTime.Now.Date.Year)==true)
{
intmonth=29; //闰年
}
else
{
intmonth=28; //平年
}

2、获取指定月份的天数

格式为:System.DateTime.DaysInMonth(int 指定的年份,int 指定的月份);

一、当前月份的天数

int idate=System.DateTime.DaysInMonth(System.DateTime.Now.Year,System.DateTime.Now.Month);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: