public static T ObjectToEnum(object o) { try { return (T)Enum.Parse(typeof(T), o.ToString(), true); }catch { return default(T); //retrun 0 // your code } }
本文共 367 字,大约阅读时间需要 1 分钟。
public static T ObjectToEnum(object o) { try { return (T)Enum.Parse(typeof(T), o.ToString(), true); }catch { return default(T); //retrun 0 // your code } }
转载于:https://www.cnblogs.com/ericyi/p/3924630.html