C# 获取当前月份天数的三种方法总结
作者:互联网
方法一: //最有含量的一种
int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(DateTime.Now.Year ,DateTime.Now.Month);
方法二://最奇怪的一种
DateTime dtNow = DateTime.Today;
int days = dtNow .AddDays(1 – dtNow .Day).AddMonths(1).AddDays(-1).Day;
方法三: //最常规的一种
DateTime dtNow = DateTime.Now; int days = DateTime.DaysInMonth(dtNow.Year ,dtNow.Month);
标签:dtNow,C#,天数,days,DateTime,int,三种,Now,Day 来源: https://www.cnblogs.com/wenlong2019/p/16288352.html