我想讓我的枚舉返回字符串值。不是Enum描述,它們必須返回一個字符串值,而不是int。下面的代碼示例正是我的想法,但顯然不能編譯。可以枚舉返回字符串而不是整數?
public enum TransactionType
{
CreditCard = "C",
DebitCard = "D",
CreditCardAuthenticationWithAuthorization = "CA",
DebitCardAuthenticationWithAuthorization = "DA"
}
任何想法?
你怎麼稱呼你的枚舉成員到底是什麼? –