返回日期的月初与月末

string yyyymm="201111";

string firstdate = yyyymm.Substring(0, 4) + "/" + yyyymm.Substring(4, 2) + "/" + "01";  //2011/11/01
string lastdate = yyyymm.Substring(0, 4) + "/" + yyyymm.Substring(4, 2) + "/" + DateTime.DaysInMonth(int.Parse(yyyymm.Substring(0, 4)), int.Parse(yyyymm.Substring(4, 2)));  //2011/11/30

Any fool can write code that a computer can understand. Good programmers write code that humans can understand. –Martin Fowler
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/gerryge/p/2238829.html