我有一个枚举
enum myEnum2 { ab, st, top, under, below}
Run Code Online (Sandbox Code Playgroud)
我想编写一个函数来测试myEnum中是否包含给定值
类似的东西:
private bool EnumContainValue(Enum myEnum, string myValue)
{
return Enum.GetValues(typeof(myEnum))
.ToString().ToUpper().Contains(myValue.ToUpper());
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为无法识别myEnum参数.