First time here? You are looking at the most recent posts. You may also want to check out older archives or the tag cloud. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS. Thank you for visiting! (hide this)

Enum

There are 2 entries for the tag Enum

Why you should never use a boolean field (use an Enum instead)

Over the last few months I worked, on my spare time, on a new web development project: the site for the Web.NET Conference. It was a refreshing experience, going back working on custom development on ASP.NET MVC 4 and all the latest bits of technology. That gave me quite a few ideas for posts, so over the next weeks I'm going to blog about some of the bits and pieces of code that I think are worth sharing with the community, like ActionResults, HtmlHelpers together with my first real-coding experiences with RavenDb. As first post I’m not focusing...

String to Enum

This might seems a pretty trivial problem, but every time I've to get an Enum given its name I forgot how to do it, and I've to look for it on Google. So, is there a better way to remember something you always forget than writing a post about it? Back to the problem: going from an Enum to its numeric value or its string representation is quite easy: /* Enum to string */ string stringValue = enumVal.ToString(); /* Enum to numeric value */ int numericVal = (int) enumVal; And going from a numeric value to the Enum is quite as easy: /* Numeric value...