我想知道为什么当我尝试不将重复的对象添加到列表中时,它仍然被添加了。
例如,对于先前的项 id = 1 和名称 = test,如果我有另一个具有相同 id 和相同名称的对象,则仍将其添加...
if (thePreviousList.Contains(thePreviousItem))
{
}
else
{
thePreviousList.Add(thePreviousItem);
}
例如,对于先前的项 id = 1 和名称 = test,如果我有另一个具有相同 id 和相同名称的对象,则仍将其添加...
Dictionary(Of TKey, TValue)
而不是列表。 - Conrad Frix