如果我有具有 Payment 属性的 Customer 对象,该属性是自定义枚举类型和十进制值的字典,例如
Customer.cs
public enum CustomerPayingMode
{
CreditCard = 1,
VirtualCoins = 2,
PayPal = 3
}
public Dictionary<CustomerPayingMode, decimal> Payment;
在客户端代码中,我在向字典中添加值时遇到问题,尝试这样
Customer cust = new Customer();
cust.Payment = new Dictionary<CustomerPayingMode,decimal>()
.Add(CustomerPayingMode.CreditCard, 1M);