方法:Enum.IsDefined

参数

enumType
类型:System.Type
枚举类型。
value
类型:System.Object
enumType 的常数的值或名称。
[Flags] public enum PetType
{
None
= 0, Dog = 1, Cat = 2, Rodent = 4, Bird = 8, Reptile = 16, Other = 32
};

object value;

Console.WriteLine(
"{0}: {1}", value, Enum.IsDefined(typeof(PetType), value));

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2022-02-07
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-07
  • 2021-09-07
  • 2021-07-06
  • 2022-12-23
  • 2022-02-06
  • 2022-02-13
相关资源
相似解决方案