使用此处描述的扩展方法:
Testing t = Enum.GetValues(typeof(Testing)) .Cast<Testing>() .FirstOrDefault(v => v.GetDescription() == descriptionToMatch);
如果找不到匹配的值,它将返回
(Testing)0(您可能想
None在枚举中为该值定义一个成员)

使用此处描述的扩展方法:
Testing t = Enum.GetValues(typeof(Testing)) .Cast<Testing>() .FirstOrDefault(v => v.GetDescription() == descriptionToMatch);
如果找不到匹配的值,它将返回
(Testing)0(您可能想
None在枚举中为该值定义一个成员)