Click here to Skip to main content
   

C#

 
AnswerRe: C# progam call second C# program PinprotectorPete O'Hanlon10-Oct-12 23:21 
QuestionCitrix Session PinmemberArun Philip Reynolds10-Oct-12 9:30 
AnswerRe: Citrix Session PinmemberEddy Vluggen11-Oct-12 0:57 
QuestionEnumerate through the values of a enum PinmemberSentenryu10-Oct-12 8:38 
ok, I Know about Enum.GetValues(), but what i want to know if is possible is to do a foreach through the values of a enum such as i can do the following:
 
foreach(var value in enum){
   list.Add(new SelectListItem(){
       Text = value.ToString(),
       Value =  ((int)value).ToString()
   });
}
 
say that i have the following enum:
 
enum States{
       Running,
       Stoped,
       Paused
}
 
the only way to accomplish what i described above is through the use of Enum.GetValues() and Enum.GetNames()? or there is some syntax sugar?
 
I'm asking more out of curiosity than anything else Wink | ;)
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

AnswerRe: Enumerate through the values of a enum PinmvpDave Kreskowiak10-Oct-12 9:01 
GeneralRe: Enumerate through the values of a enum PinmemberSentenryu10-Oct-12 9:18 
GeneralRe: Enumerate through the values of a enum PinmvpDave Kreskowiak10-Oct-12 9:29 
GeneralRe: Enumerate through the values of a enum PinmemberSentenryu10-Oct-12 9:55 
GeneralRe: Enumerate through the values of a enum PinmemberMr. Tapan Kumar10-Oct-12 10:47 
GeneralRe: Enumerate through the values of a enum PinmemberJ4amieC10-Oct-12 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.150128.1 | Last Updated 28 Jan 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid