|
楼主 |
发表于 2020-4-25 23:45:01
|
显示全部楼层
在MODEINFO层用HASHTABLE好像有点行不通呀
public class CartItemInfo {
// Internal member variables
private int quantity = 1;
private string itemId;
private string name;
private string type;
private decimal price;
private string categoryId;
private string productId;
/// <summary>
/// Default constructor
/// </summary>
public CartItemInfo() { }
/// <summary>
/// Constructor with specified initial values
/// </summary>
/// <param name="itemId">Id of item to add to cart</param></param>
/// <param name="name">Name of item</param>
/// <param name="qty">Quantity to purchase</param>
/// <param name="price">Price of item</param>
/// <param name="type">Item type</param>
/// <param name="categoryId">Parent category id</param>
/// <param name="productId">Parent product id</param>
public CartItemInfo(string itemId, string name, int qty, decimal price, string type, string categoryId, string productId) {
this.itemId = itemId;
this.name = name;
this.quantity = qty;
this.price = price;
this.type = type;
this.categoryId = categoryId;
this.productId = productId;
}
// Properties
public int Quantity {
get { return quantity; }
set { quantity = value; }
}
public decimal Subtotal {
get { return (decimal)(this.quantity * this.price); }
}
public string ItemId {
get { return itemId; }
}
public string Name {
get { return name; }
}
public string Type {
get {
return type;
}
}
public decimal Price {
get { return price; }
}
public string CategoryId {
get {
return categoryId;
}
}
public string ProductId {
get {
return productId;
}
}
}
}
我是想把这里的属性换成索引取值的方法,这样不知道会引响多大的速度呀和效率呀,同时如果用索引器的话,是不是还要事先去NEW一个呢 |
|