Generic Function to convert string to Enum

private T GetEnumFromString<T>(string value)
  {
     try
        {
           T t;
           t = (T)Enum.Parse(typeof(T), value);
           return t;
        }
     catch (Exception E)
        {
           return (T)((object)0);
        }
   }

No comments:

Post a Comment