int Month = 9;
//第一天
DateTime TheFirstDay = Convert.ToDateTime(DateTime.Now.Year + "/" + Month + "/1 00:00:00");
//最后一天
DateTime TheLastDay = TheFirstDay.AddMonths(1).AddDays(-TheFirstDay.Day).AddHours(23).AddMinutes(59).AddSeconds(58);
string first = "第一天:" + TheFirstDay;
string end = "最后一天:" + TheLastDay;
Console.WriteLine(first);
Console.WriteLine(end);
时间: 2024-10-23 22:19:23