DateTime date1 = new DateTime(2013, 8, 10);
DateTime date2 = new DateTime(2013, 8, 15);
Dictionarydic = new Dictionary ();
string s = "";
for (; date1 <= date2; ) {
switch (date1.DayOfWeek) {
case DayOfWeek.Sunday:
s = "星期天";
break;
..... // 星期一到星期五的值
case DayOfWeek.Saturday:
s = "星期六";
break;
}
dic.Add(date1, s);
date1 = date1.AddDays(1);
}
C#代码如上, 得到的结果保存在dictionary对象中.