C# List collection Contains invalid problem

I changed the bug today and encountered a strange problem. The entity object was clearly added to the collection, but List.Contains(entity); just didn't work.

Find a way to replace it temporarily

bool flag = list.Exists(o => o.Id == entity.Id);
if (!flag)
{
    list.Add(entity);

Who has studied it and hopes to let me know.

Guess you like

Origin blog.csdn.net/qq_41630695/article/details/114443255