我研究了枚举,它只需要整数输入并返回相应的值.我想实现同样的东西,但我只有字符串作为输入.我想做以下工作 -
enum Types {
"Absolute", //"abs"
"PURE", //"PRE"
"MIXED" //"MXD"
}
Run Code Online (Sandbox Code Playgroud)
可能的陈述可能是 -
string sTpes = Types("abs"); //this should return "Absolute"
Run Code Online (Sandbox Code Playgroud)
要么
string sTpes = Types("MXD"); //this should return "MIXED"
Run Code Online (Sandbox Code Playgroud)
如果不使用枚举,请建议我实现这一目标的可能方法.
谢谢.