C#获取指定月指定周的日期范围
/// <summary>
/// 获取指定月份指定周数的开始日期
/// </summary>
/// <param name="year">年份</param>
/// <param name="month">月份</param>
/// <param name="index">周数</param>
/// <returns></returns>
private DateTime GetStartDayOfWeeks(int year, int month, int index)
{
if (year < 1600 || year > 9999)
{
MessageBox.Show("年份超限");
return DateTime .MinValue ;
}
if (month < 0 || month > 12)
{
MessageBox.Show("月份错误");
return DateTime .MinValue ;
}
if (index < 1)
{
MessageBox.Show("周数错误");
return DateTime.MinValue;
}
DateTime startMonth = new DateTime(year, month, 1); //该月第一天
int dayOfWeek = 7;
if (Convert.ToInt32(startMonth.DayOfWeek.ToString("d")) > 0)
dayOfWeek = Convert.ToInt32(startMonth.DayOfWeek.ToString("d")); //该月第一天为星期几
DateTime startWeek =
补充:软件开发 , C# ,