求助。如何输入一个年月日后,得到该月的天数? 如上。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DateTime dt = Convert.ToDateTime( string );dt.Month = dt.Month + 1;dt.Day = 1;dt.AddDay( -1 );这个时候的Day就是该月的天数了……我记得好像有更好的办法,忘记了,等后面的人来吧。 找到了DateTime.DaysInMonth( DateTime )返回指定年份中指定月份的天数 DateTime dt = Convert.ToDateTime( string );int intDays=DateTime.DaysInMonth( DateTime );返回指定年份中指定月份的天数 public static System.Int32 DaysInMonth ( System.Int32 year , System.Int32 month ) System.DateTime 的成员摘要: 返回指定年份中指定月份的天数。 参数:year: 年份。 month: 月份(介于 1 到 12 之间的一个数字)。 返回值: 指定 year 中 month 的天数。 例如,如果 month 等于 2(表示二月),则返回值为 28 或 29,具体取决于 year 是否为闰年。 异常:System.ArgumentOutOfRangeException: month 小于 1 或大于 12。 DateTime dt = Convert.ToDateTime( string );int intDays=DateTime.DaysInMonth( dt.Year,dt.Month);返回指定年份中指定月份的天数 DateTime dt = Convert.ToDateTime( string );int Days=DateTime.DaysInMonth( DateTime ); 实现两台机器间通信 求 类似于CSDN用户登录的验证码控件 网络映射驱动器 条码、标签、套打设计器(V1.0.0.5)2009-02-01更新 C#中 提取PDF文件里的图片! 关于asp页面跳转的问题 C#合成图片 登陆时间。退出时间代码 网络音频的聊天代码能否多端口接收和发送语音 怎么安装不了Intel Peer-to-Peer Accelerator Kit? 请教:为什么这段代码总是显示"无法写入注册表". 怎么查找窗体上的不可视控件,例如DataTable或DataSet控件
dt.Month = dt.Month + 1;
dt.Day = 1;
dt.AddDay( -1 );
这个时候的Day就是该月的天数了……
我记得好像有更好的办法,忘记了,等后面的人来吧。
返回指定年份中指定月份的天数
int intDays=DateTime.DaysInMonth( DateTime );
返回指定年份中指定月份的天数
System.DateTime 的成员摘要:
返回指定年份中指定月份的天数。 参数:
year: 年份。
month: 月份(介于 1 到 12 之间的一个数字)。 返回值:
指定 year 中 month 的天数。 例如,如果 month 等于 2(表示二月),则返回值为 28 或 29,具体取决于 year 是否为闰年。 异常:
System.ArgumentOutOfRangeException: month 小于 1 或大于 12。
int intDays=DateTime.DaysInMonth( dt.Year,dt.Month);
返回指定年份中指定月份的天数
int Days=DateTime.DaysInMonth( DateTime );