Can we get a generic Parse method on Enum in the next version of .NET?

I have one tiny pet peeve about Enum.Parse. It's so  verbose with the typeing (both meanings of the word).

Here's what you have to do today:

   1:  public enum MyEnum
   2:  {
   3:    One,
   4:    Two
   5:  }
   6:   
   7:  MyEnum me = (MyEnum)Enum.Parse(typeof(MyEnum), "One");

what I'd like to see is an overload of Parse that supported a generic param like this:

   1:  MyEnum me = Enum.Parse<MyEnum>("One");
Published Wednesday, July 05, 2006 5:29 PM by findleyd
Filed under:

Comments

# Generic Enum Parse

Wednesday, July 05, 2006 7:07 PM by Ancora Imparo

David Findley asks for a generic way to call Enum.Parse in C# v.Next.The code below does not have full

# Generic Parse method on Enum - a solution

Thursday, July 06, 2006 5:11 AM by Wimdows.NET

David Findley writes about how he wishes we had a generic Parse method on the Enum class in .NET 2.0.Though

# [Linq] String.ParseToEnum&amp;lt;T&amp;gt; &amp;#233;tendre un Type avec ses propres m&amp;#233;thodes

Monday, July 10, 2006 6:52 PM by Cyril 's Blog

Dans ce post&amp;nbsp;&amp;nbsp;l'auteur dit qu'il aimerait&amp;nbsp;qu'avec les prochaines version de .net il y...

# re: Can we get a generic Parse method on Enum in the next version of .NET?

Wednesday, August 22, 2007 11:07 AM by neil

Its a pain alright , i stuck a peice on my blog about it.

Leave a Comment

(required) 
(required) 
(optional)
(required)