0
我需要一些帮助来总结小数点。总和列表查看小数点
我使用下面的代码来显示一个列表视图,并希望在列表视图的最后一行显示销售价格的总和。
foreach (Stock c in stock)
{
string[] subitems = new string[4];
subitems[0] = c.ID.ToString();
subitems[1] = c.ItemDescription;
subitems[2] = "£" + c.PurchasePrice;
subitems[3] = "£" + c.SalePrice;
ListViewItem listItem = new ListViewItem(subitems);
SalelistView.Items.Add(listItem);
ItemNumberTofFnd.Text = "";
}
如何显示总销售价格?
我试过decimal T += c.SalePrice
,但我很不确定,因为我之前没有做过这种事情。
十进制T + = c.SalePrice肯定会计算总价。在开始循环之前,不要忘记将'T'的值重置为0 – gypsyCoder