gpt4 book ai didi

c# - 编写此属性和构造函数代码的更好方法?

转载 作者:行者123 更新时间:2023-11-30 21:18:49 25 4
gpt4 key购买 nike

我正在使用 Visual Studio 2008 (C#)。有没有更好的方法来编写这段代码?我是一个可怜的程序员。

#region Properties
public string ItemCode
{
get { return _itemCode; }
set { _itemCode = value; }
}

public string ItemName
{
get { return _itemName; }
set { _itemName = value; }
}

public decimal? StockInHand
{
get { return _stockInHand; }
set { _stockInHand = value; }
}

public decimal? AlertLevelQty
{
get { return _alertLevelQty; }
set { _alertLevelQty = value; }
}

public string Unit
{
get { return _unit; }
set { _unit = value; }
}

public decimal? Discount
{
get { return _discount; }
set { _discount = value; }
}

public string WhetherInPercent
{
get { return _whetherInPercent; }
set { _whetherInPercent = value; }
}

public int CategoryID
{
get { return _categoryID; }
set { _categoryID = value; }
}
#endregion

#region Constructors
public ItemMaster()
{ }

public ItemMaster(string argItemName, string argItemCode, decimal? argStockInHand, decimal? argAlertLevelQty, string argUnit, decimal? argDiscount, string argWhetherInPercent, int argCategoryID)
{
this.ItemName = argItemName;
this.ItemCode = argItemCode;
this.StockInHand = argStockInHand;
this.AlertLevelQty = argAlertLevelQty;
this.Unit = argUnit;
this.Discount = argDiscount;
this.WhetherInPercent = argWhetherInPercent;
this.CategoryID = argCategoryID;
}
#endregion

最佳答案

您的代码没有任何问题。

我是一个懒惰的程序员,所以我经常在我的代码中使用自动属性。

public string Unit { get; set; }

关于c# - 编写此属性和构造函数代码的更好方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4059805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com