Skip to content

Casting an enum

April 13, 2012
public enum Technologies
    Html = 1,
    NodeJs = 2,
    MySql = 3,
    Javascript = 4,
    JQuery = 5,
What I found out today, after what feels like a long week, was a relatively simple answer to getting a number out of an enEnum I created.
Casting an Enum is simply done as: - 
int something = (int) Technologies.NodeJs;
So you DON'T need to do int something = Convert.ToInt(Technologies.NodeJs.ToString()); which is wrong!

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: