How do I get the first day in a week Week, Year (gregorian calendar) in C#?
I need to calculate the date of the first day in a calendar week given a year/week, e.g.
Week 53 in 2009 -> Mon, 28.12.2009
开发者_运维技巧Week 1 in 2010 -> Mon, 04.01.2010How would you wirte that code?
PS: In the Gregorian calendar the first week of a year is the first week with 4 days.
If you don't want to do all the calculation yourself, use the System.Globalization.Calendar
class. I think you can use the GetDayOfYear()
method to get what you need.
Check this MSDN library for the example.
精彩评论