Wednesday, June 01, 2005

Get the Number of weeks from particular Month



class MonthWeek
{


static void Main(string[] args)
{
DateTime dt = new DateTime(2005,2,1);
int days = DateTime.DaysInMonth(2005,2);
int week=0;
for(int i =1;i <= days ;i++)
{
if(dt.DayOfWeek.ToString()=="Sunday")
{
week += 1 ;
}
dt = dt.AddDays(1);

}
Console.WriteLine(week);
Console.ReadLine();
}
}

No comments: