首页 > 代码库 > Object To Enum

Object To Enum

        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            }        }