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.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Getting the value of an enum 2
Convert DropDownList values to enum values 2
Enum TypeConverter 3
Enum Extentions 7
Generic.List 1
about enum 3
Function help 1
Generic List. Remove duplicate 2

Back
Top