I'm trying to make a condition where I would check if there is a value in List
, 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}))
Always valid, even if the value already exists in the list