// ReSharper disable once CheckNamespace namespace System { public static partial class EnumExtensions { /// /// 返回一个布尔值,该值指示给定的整数值或其名称字符串是否存在于指定的枚举中 /// /// /// 如果 enumType 中的某个常量的值等于 value,则为 ;否则为 public static bool IsDefined(this Enum value) => Enum.IsDefined(value.GetType(), value); public static TEnum ConvertToEnum(this int value) where TEnum : struct, IConvertible => Enum2.ConvertToEnum(value); public static int ConvertToInt32(this TEnum value) where TEnum : struct, IConvertible => Enum2.ConvertToEnum(value); } }