Gecenlerde haftayi ve yili bilip de haftanin ilk ve son gununu hesaplama ihtiyacim duydum. Umarim sizin de isinize yarar..
public class CalendarHelper
{
/// <summary>
/// Calculates start and end date of a week for a specific year.
/// </summary>
/// <param name="year">Year</param>
/// <param name="week">Week number</param>
/// <param name="startDate">Calculated start date of week</param>
/// <param name="endDate">Calculated end date of week</param>
public static void StartEndDateOfWeek(int year, int week, out DateTime startDate, out DateTime endDate)
{
// First of January
DateTime jan1 = new DateTime(year, 1, 1);
// Calculation is done according to the first day of week is monday but includes the offset,
// so it will be correct for sunday and other first day of week.
int daysOffset = (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - (int)jan1.DayOfWeek;
DateTime firstMonday = jan1.AddDays(daysOffset);
// Find the first week.
int firstWeek = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(jan1, CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule,
CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek);
if (firstWeek <= 1)
{
week -= 1;
}
startDate = firstMonday.AddDays(week * 7);
endDate = startDate.AddDays(6);
}
}