摘要:
这题与《列出本月所有星期天的日期》有点相似,稍微变动一下,即可完成。publicIEnumerable<DateTime>AllSundaysInYear(intyear){System.Globalization.CultureInfoci=newSystem.Globalization.CultureInfo("en-US");for(intm=1;m<=12;m++){intdays=ci.Calendar.GetDaysInMonth(year,m);for(inti=1;i<=days;i++){if(newDateTime(year,m, 阅读全文
摘要:
本作业题是列出本月所有星期天的日期。publicIEnumerable<DateTime>AllSundaysInMonth(intyear,intmonth){System.Globalization.CultureInfoci=newSystem.Globalization.CultureInfo("en-US");intdays=ci.Calendar.GetDaysInMonth(year,month);for(inti=1;i<=days;i++){if(newDateTime(year,month,i).DayOfWeek==DayOfWeek 阅读全文
摘要:
作业问题与要求是列出本月偶数的日期。如果会做 《显示本月每一天日期》,此题也许不是问题了。publicIEnumerable<DateTime>AllEvenDatesInMonth(intyear,intmonth){intdays=DateTime.DaysInMonth(year,month);for(inti=1;i<=days;i++){if(i%2==0)yieldreturnnewDateTime(year,month,i);}} 阅读全文
摘要:
老师布置的作业,一直没有完成。现在有一些时间,继续完成它们。其中一题是列出当前月的每一天。publicIEnumerable<DateTime>AllDatesInMonth(intyear,intmonth){intdays=DateTime.DaysInMonth(year,month);for(inti=1;i<=days;i++){yieldreturnnewDateTime(year,month,i);}} 阅读全文