Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

How can i implement the below code in visual webpart


int month = 1;
int year = 2013;
var cal = System.Globalization.CultureInfo.CurrentCulture.Calendar;
IEnumerable<int> daysInMonth = Enumerable.Range(1, cal.GetDaysInMonth(year, month));
List<tuple><int,>> listOfWorkWeeks = daysInMonth .Select(day => new DateTime(year, month, day)) .GroupBy(d => cal.GetWeekOfYear(d, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)) .Select(g => Tuple.Create(g.Key, g.First(), g.Last(d => d.DayOfWeek != DayOfWeek.Saturday && d.DayOfWeek != DayOfWeek.Sunday))) .ToList();
// Item1 = week in year, Item2 = first day, Item3 = last working day int weekNum = 1;
foreach (var weekGroup in listOfWorkWeeks)
{
Console.WriteLine("Week{0} = {1} {2} to {1} {3}" , weekNum++ , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month) , weekGroup.Item2.Day , weekGroup.Item3.Day);
}
Posted
Updated 25-May-13 16:50pm
v2
Comments
OriginalGriff 25-May-13 5:34am    
What have you tried?
Where are you stuck?
Nelek 25-May-13 6:17am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900