c#如何快速的根据枚举中的对象的名字获取枚举对象?

2024-12-26 06:38:13
推荐回答(3个)
回答1:

楼上荒谬

RmsCode s = (RmsCode)Enum.Parse(typeof(RmsCode), "用车类型");

回答2:

private void button1_Click(object sender, EventArgs e)
{
string s = "用车类型";
RmsCode rc = (RmsCode)Enum.Parse(typeof(RmsCode), s);
MessageBox.Show(((int)rc).ToString());
}

回答3:

(int)test;//直接强制转换