我正在尝试比较列表视图中是否已经存在项目。
它说 :
使用未分配的局部变量“alreadyInList”
bool alreadyInList;
foreach (var itm in lvCart.Items)
{
if (itm == item)
{
alreadyInList = true;
break;
}
}
if(!alreadyInList)
{
lvCart.Items.Add(new ListViewItem(new string[] { item, price, noi }));
}