1
I’m trying to make a condition, where I would check, whether in a List
there is a value, so I created the following:
private void Itens_Edit(object sender, EventArgs e)
{
if(editar == 1)
{
int a = Convert.ToInt32(gridView5.GetRowCellValue(gridView5.GetSelectedRows()[0], "ITEM"));
int b = Convert.ToInt32(gridView5.GetRowCellValue(gridView5.GetSelectedRows()[0], "QUANTIDADE"));
// se o item editado, conter na lista editable, adiciona na lista edit, para fazer update
if (List_Itens_Editable.Contains(a))
{
// se não existir na lista edit, adiciona se nao nao.
if(!item_edit.Contains(new Part_edit { item = a}))
{
item_edit.Add(new Part_edit { item = a, qnt = b});
}
}
}
}
however, the condition:
if(!item_edit.Contains(new Part_edit { item = a}))
It is always valid, even if the value already exists in the list