public static T ObjectToEnum<T>(object o) { try { return (T)Enum.Parse(typeof(T), o.ToString(), true); }catch { return default(T); //retrun 0 // your code } }
Object To Enum
时间: 2024-09-21 16:33:32
public static T ObjectToEnum<T>(object o) { try { return (T)Enum.Parse(typeof(T), o.ToString(), true); }catch { return default(T); //retrun 0 // your code } }
Object To Enum