我遇到了几种在 asp.net 中编写业务逻辑的方法,但我想知道下面的 2 个示例,使用结构存储类变量有什么好处:
namespace Shopping
{
public struct ShoppingCart
{
public string Color;
public int ProductId;
}
public partial class MyShoppingCart
{
public decimal GetTotal(string cartID)
{
}
// Some other methods ...
}
}
namespace Shopping
{
public partial class MyShoppingCart
{
public string Color{ get; set; }
public int ProductId{ get; set; }
public decimal GetTotal(string cartID)
{
}
// Some other methods ...
}
}