Convert string to enum


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public static T StringToEnum<T>(string name)
  2. {
  3. return (T)Enum.Parse(typeof(T), name);
  4. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.