0

我有一个以下枚举

[Flags]
public enum CreditCardType
{
None = 0x0,
[EnumLabel("Visa")]                Visa           = 0x1,
[EnumLabel("Maestro")]             Maestro        = 0x2,
[EnumLabel("Master Card")]         Master         = 0x4,

}

用户以字符串形式回复这些选项。我正在尝试将字符串转换为枚举

CreditCardType=(CreditCardType)Enum.Parse(typeof(CreditCardType),"Visa");

在此我收到以下错误。未找到请求的值“Visa”。

我哪里错了?请帮忙。

4

1 回答 1

0

Friends I found my error. I was trying to parse CreditCardType.Visa instead of Visa. Thanks all for the help.Sorry for the confusion.

于 2012-06-28T08:44:26.583 回答