C# 检查列表是否具有object by 2属性
我想检查我的单元格列表中是否有任何单元格具有特定列和特定行,如果有,请删除该单元格。如果没有,请添加包含该行和该列的单元格。我的尝试,但无法检查行,因为不确定如何检查2个属性:C# 检查列表是否具有object by 2属性,c#,list,C#,List,我想检查我的单元格列表中是否有任何单元格具有特定列和特定行,如果有,请删除该单元格。如果没有,请添加包含该行和该列的单元格。我的尝试,但无法检查行,因为不确定如何检查2个属性: int index = cells.FindIndex(item => item.myColumn == col); if (index >= 0) { // element exists, do what you need if (cell.myColumn == col &&
int index = cells.FindIndex(item => item.myColumn == col);
if (index >= 0)
{
// element exists, do what you need
if (cell.myColumn == col && cell.myRow == row)
{
cells.Remove(cell);
}
}
else
{
Bitmap image = myMapController.myMap.cellBgImage;
cells.Add(new Cell(col, row, new CellSide(0, false), new CellSide(0, false), myMapController.myMap, image));
}
是否有任何东西阻止您执行第一行上的item=>item.myColumn==col&&item.myRow==row?没有。可以,没有错误。谢谢刚刚开始。