我所遇到的一些方法写在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 ...
}
}
感谢您的明确解释。 – k80sg
剽窃 - 第一段是从[什么时候在C#中使用结构体]批量拷贝的(http://stackoverflow.com/q/521298) –
即使所有的编辑,这里仍然没有任何* original *材料。 – jmort253