【发布时间】:2012-04-13 06:36:58
【问题描述】:
我想知道为什么当我尝试不将我的对象添加到列表中时,它仍然在添加它
if (thePreviousList.Contains(thePreviousItem))
{
}
else
{
thePreviousList.Add(thePreviousItem);
}
例如上一个项目 id = 1 和 name = test 如果我有另一个具有相同 ID 和相同名称的对象,它仍然会添加它...
【问题讨论】:
-
也许你想使用
Dictionary(Of TKey, TValue)而不是列表
标签: c# asp.net list duplicates