I am wondering why when I try to not add my object in the list when it’s duplicate it’s still adding it
if (thePreviousList.Contains(thePreviousItem))
{
}
else
{
thePreviousList.Add(thePreviousItem);
}
For example thepreviousitem id = 1 and name = test
And if i have another object with the same id and same name it will still add it…
If you don’t want to override Equals, you can use LINQ to check if an object with the same ID and name (which is not necessarily the same object) already exists: