private int weekNumber()
{
string firstDateText = DateTime.Now.Year.ToString() + "年1月1日";
DateTime firstDay = Convert.ToDateTime(firstDateText);
int theday;
if (firstDay.DayOfWeek == DayOfWeek.Sunday || firstDay.DayOfWeek == DayOfWeek.Monday)
{
theday = 0;
}
else if (firstDay.DayOfWeek == DayOfWeek.Tuesday)
{
theday = 1;
}
else if (firstDay.DayOfWeek == DayOfWeek.Wednesday) { theday = 2; }
else if (firstDay.DayOfWeek == DayOfWeek.Thursday) { theday = 3; }
else if (firstDay.DayOfWeek == DayOfWeek.Friday)
{
theday = 4;
}
else
{
theday = 5;
}
DateTime nowDate = DateTime.Now;
int weekNum = (nowDate.DayOfYear + theday) / 7 + 1;
return weekNum;
}
转载于:https://www.cnblogs.com/freedom831215/archive/2009/11/30/1613536.html