Convert a string into an enum(blogs.msdn.com)
submitted by jonas(2215) 4 years, 1 month ago
Tim Sneath writes some C# to convert a string into an enum.
2 comments |category: C# |Views: 26 Tweet
tags: C# another
Add a live kick counter to your blog >>
You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:
Simply copy and paste this HTML into your blog post.
posted by DanRigsby(1880) 4 years ago 0
You could also try this: http://www.danrigsby.com/blog/index.php/2007/12/16/missing-static-generic-alternatives-in-enum-class/ It would allow you to do like so: Color color = EnumUtilities.ParseEnum<Color>("Red"); Instead of: Color color = (Color)Enum.Parse(typeof(Color), "Red");
Reply
posted by cherian(35) 4 years ago 0
Take a look at this implementation with attributes. http://www.gigpeppers.com/blog/post/Convert-enum-to-string-with-attributes.aspx
All tags Your tags
Suggest a new category
dpeterson(1273)
Telerik(409)
fdub(381)
amit.jain(268)
BlackWasp(259)
RobertTheGrey(259)
jalpesh(252)
bsenoff(240)
KMillerr(226)
vijayst(223)