本文介绍了如何获取特定年份的周数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取特定年份的周数...?
Hi,
How to get count of week for particular year...?
推荐答案
float week = (DateTime.IsLeapYear(year) ? 366 : 365) / 7
或
OR
int year = 2004;
DateTime dt = new DateTime(year, 12, 31);
int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
dt,
CalendarWeekRule.FirstFourDayWeek,
DayOfWeek.Monday);
private double CountNoOfWeeks(int year)
{
DateTime date1 = new DateTime(year, 1, 1);
DateTime date2 = date1.AddYears(1);
double weeks = (date2 - date1).TotalDays / 7;
return weeks;
}
这篇关于如何获取特定年份的周数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!