Posted by: R Manimaran | July 2, 2008

Accessing Enum Elements using For..each

//Enumeration

Enum Days

{

Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday

}

//accessing

ArrayList aDays=new ArrayList();

Foreach(string day in Enum.GetNames(typeof(Days))

{

aDays.Add(day);

}

//Bind Enum to DropDown List

myDropDownList.DataSource = Enum.GetNames( typeof(Days) );
myDropDownList.DataBind();

Advertisements

Responses

  1. Thanks for the post

  2. Super Post….


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

Categories

%d bloggers like this: