我试图让我的代码检查某个字符串是否在枚举类型中。这就是我所拥有的:
public enum CurrencyAmt {twenty(20), ten(10), five(5), toonies(2), toony(2), loonies(1), loony(1), quarters(0.25),
quarter(0.25), dimes(0.1), dime(0.1), nickels(0.05), nickel(0.05), pennies(0.01), penny(0.01);
private int type;
private double value;
CurrencyAmt (int i)
{
this.type = i;
}
CurrencyAmt (double i)
{
this.value = i;
}
}
定义我的枚举类型。和表达
(Enum.IsDefined(typeof(CurrencyAmt), inputAt)
检查字符串“inputAt”是否在枚举中。但是,我收到错误 CurrencyAmt 无法解析为变量。有任何想法吗?