Posted By

samwa on 01/04/11


Tagged

enum helper c#


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

samwa


Convert string to enum


 / Published in: C#
 

URL: http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-how-to-get-an-enum-from-a-string

  1. public static T StringToEnum<T>(string name)
  2. {
  3. return (T)Enum.Parse(typeof(T), name);
  4. }

Report this snippet  

You need to login to post a comment.