所以我有这个开关,以设置等待时间传递枚举命令行参数
public int Option(string arg)
{
switch (arg)
{
case "/t:Max":
return 0;
case "/t:Med":
return 1000;
case "/t:Min":
return 2000;
default: return 0;
}
}
如何使用枚举为/吨:民/吨:地中海,/t.Max以更换开关?
确实是这样的:
enum t
{
/t:Min,
/t:Med,
/t:Max
};
Enum.TryParse()浮现在脑海...... – 2012-08-02 13:36:15
@JamesMichaelHare:虽然它用一个枚举替换了字符串,但它不会消除对该开关的需要。除非数字是在enum常量中编码的,我可能会称其为hack :-) – 2012-08-02 13:37:30
您将不得不失去/ t:部分。 – hatchet 2012-08-02 13:38:09