Another enum question

  • Thread starter Thread starter Mark Fox
  • Start date Start date
M

Mark Fox

Hello,

I have a simple question. If there is an enum:

public enum Hello
{
First = 1,
Second = 2,
Third = 3
}

How would I parse an integer value to select an enum:

int valueToSelect = 2;
Hello thisHello = [??Enum.Parse(typeof(Hello),
valueToSelect)??];

Any help would be appreciated! Thanks.
 
int valueToSelect = 2;
Hello thisHello = (Hello)valueToSelect;


The Best Regards,
Web Developer
Michael Tkachev
 
Michael,

Thank you! I didn't realize it was so simple.

-----Original Message-----
int valueToSelect = 2;
Hello thisHello = (Hello)valueToSelect;


The Best Regards,
Web Developer
Michael Tkachev

Mark Fox said:
Hello,

I have a simple question. If there is an enum:

public enum Hello
{
First = 1,
Second = 2,
Third = 3
}

How would I parse an integer value to select an enum:

int valueToSelect = 2;
Hello thisHello = [??Enum.Parse(typeof(Hello),
valueToSelect)??];

Any help would be appreciated! Thanks.


.
 
Back
Top