You can use Contains
status = false;
for (var i = 0; i < ids.Count; i++)
{
if (list.Count > 0 && !list.Contains(ids[i])){
list.Add(ids[i]); //add this, be it duplicate or not
status = true; //different element found
break; //break if this is not duplicate
} else {
//do something for duplicate
list.Add(ids[i]); //add this, be it duplicate or not
}
}
Contains
can check if your item already exists in the List
7
solved How to break from the loop when adding values to the list object which is distinct from already added values of the list?