Sparrow's Lair

Just my random musing on life, being a sparrow at various places in the world and all things development related

Friday, May 26, 2006

Playing with enums

I was sorely vexed today not to be able to spend lunch at the harbour with my husband, watching the sparrows frolic amongst the crowds. A seagull has taken a fancy to us lately, sitting above our heads and screaming piteously for whatever crumbs we might be inclined to leave behind. I saved a sandwich crust for him yesterday but he tarried too long and another shot in and stole it. He was sorely vexed too...

But onto other matters, and the apparent difficulty of getting the integer representation of an enumerated item. Getting the named string is rather easy, of course, with GetName() but the integer representation proved slightly more difficult to extract:

(int)Enum.Parse(typeof(EnumType), Enum.GetName(typeof(EnumType), EnumType.value));

0 Comments:

Post a Comment

<< Home