public void GetWMDay()
{
List<string> list = new List<string>();
string year = "";
DateTime counYear = Convert.ToDateTime(year + "-01-01"); //
DateTime nestYear = counYear.AddYears(); for (DateTime i = counYear; i < nestYear; i = i.AddDays())
{
if ((int)i.DayOfWeek == )
{ // 周日 to do } list.Add("周日" + i.ToShortDateString());
}
else if ((int)i.DayOfWeek == )
{ //周六 to do }
list.Add("周六" + i.ToShortDateString());
}
} MessageBox.Show("完成");
}
/// <summary>
/// 获得指定年,月 的周六和周日的 年月日
/// </summary>
/// <param name="year"></param>
/// <returns></returns>
public List<DateTime> GetWMDay(int year,int month)
{
List<DateTime> list = new List<DateTime>();
DateTime counYear = Convert.ToDateTime(string.Format("{0}-{1}-01",year,month));
DateTime nestYear = counYear.AddMonths();
for (DateTime i = counYear; i < nestYear; i = i.AddDays())
{
if ((int)i.DayOfWeek == )
{ // 周日 to do } list.Add(i);
}
else if ((int)i.DayOfWeek == )
{ //周六 to do }
list.Add(i);
}
}
return list;
}