Number of week occurances in a month programe using c#

This time  My TL asked me to write small program to get all the Fridays in a month with out using Calender control she asked me to take own time to create one 🙂 but i created it in 5 mins

here is the solution for the same it might be use full for you guys

// taking year month from DROP DOWN LIST’S
int yr = Convert.ToInt32(DropDownList1.SelectedValue);
int mth = Convert.ToInt32(DropDownList2.SelectedValue);
int days = DateTime.DaysInMonth(yr, mth);

no = new DateTime(yr, mth,1);
DropDownList3.Items.Clear();
for (int i = 0; i <= days; i++)
{

if (no.AddDays(i).DayOfWeek == DayOfWeek.Friday)
{
string a = no.AddDays(i).Day.ToString();
DropDownList3.Items.Add(a);

}

}

Advertisements

About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Programming and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s