Friday, May 30, 2008

Iterate through Enumeration C#

Need to iterate through an Enumeration in C#?

First create the array using following code:

Array lstProvider = System.Enum.GetValues( typeof(CommonShared.EnumProvider));

Then you can directly call the following foreach loop:

foreach (CommonShared.EnumProvider enProvider in lstProvider)
{
// do something...
}

1 comments:

Secret said...

Hello,

You method will work file in C# but not in silverlight.

Below Link provide the workaround to obtain the desired result in silverlight

http://aspdotnethacker.blogspot.com/2010/05/hello-folks-while-working-on-my-project.html