c# add value to list if not exists code example
Example 1: c# verify in class exist in list
Item wonderIfItsPresent = ...
bool containsItem = myList.Any(item => item.UniqueProperty == wonderIfItsPresent.UniqueProperty);'
Example 2: how to add to a list only items that are not already in the list c#
CurrentCollection.AddRange(NewItems.Where(x => !CurrentCollection.Any(y => y.valueToCheck == x.valueToCheck)));