【发布时间】:2014-05-14 09:29:20
【问题描述】:
我有以下枚举:
public enum ItemType
{
Foo =0,
Bar =1
}
然后是传递给方法的小写字符串。
如何将字符串与我的枚举进行比较并返回枚举。
public ItemType Method(string value)
{
///compare string to enum here and return Enum
}
并且该方法像这样接收值作为参数(注意小写)
string value = "foo"; /// or value ="bar"
ItemType type = Method(value)
【问题讨论】: