关于DateTime时间的问题 比如说 我给你一个年份月份 如 2010-8 我想知道2010年8月一共有多少天 。请问大侠们 如何做 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 dt1 2010-8-1dt1+1月 dt2 2010-9-1timespan dt2-dt1 System.DateTime.DaysInMonth(指定年,指定月); int idate=System.DateTime.DaysInMonth(2006,6); 返回值 idate 30 int days = DateTime.DaysInMonth(2010, 8); DateTime.DaysInMonth(year, month); 最简单的就是int days = DateTime.DaysInMonth(2001, 10);也可以通用加一个月,相减来计算 DateTime dt1 = DateTime.Now; dt1 = new DateTime(dt1.Year, dt1.Month, 1); DateTime dt2 = dt1.AddMonths(1); dt2 = new DateTime(dt2.Year, dt2.Month, 1); int days = (dt2-dt1).Days; 不废话int days = DateTime.DaysInMonth(2001, 10); Int32 days = DateTime.DaysInMonth(2010, 8); DateTime.DaysInMonth(2010, 8); C#与C++交互中对象的有效期问题 c#串口通信问题 c#窗体应用程序中如何在ListView特定列中动态加入多个Combox控件--谢谢!!请高手指点 如何实现右击工具栏按钮 为什么我用ODBC建了连接vfp,就是执行不了sql语句,救急!进度停了好几天 如何让windows服务启动后在任务栏中显示对应应用程序的托盘图标? 调用C#类库中一个函数就自动运行一个功能是怎么做到的 手机号码有没有什么规律? 关于C#标签的处理问题 C#如何为程序绑定mac地址 ,实现此程序只能在特定的电脑上运行 C#写的winform项目中 如何检测IE的版本??急寻高手 c#中validate类的作用
dt1+1月 dt2 2010-9-1timespan dt2-dt1
int idate=System.DateTime.DaysInMonth(2006,6);
返回值 idate 30
DateTime dt1 = DateTime.Now;
dt1 = new DateTime(dt1.Year, dt1.Month, 1);
DateTime dt2 = dt1.AddMonths(1);
dt2 = new DateTime(dt2.Year, dt2.Month, 1);
int days = (dt2-dt1).Days;