// <summary>
/// 去除List集合中的重复元素
/// </summary>
/// <param name="list">要去除重复元素的集合</param>
/// <returns>返回处理后的集合</returns>
public static List<TypeAndName> ItemFilter(List<TypeAndName> list)
{
List<TypeAndName> resultList = new List<TypeAndName>();
for (int i = 0; i < list.Count; i++)
{
for (int j = i + 1; j < list.Count; j++)
{
if (list[i].Name == list[j].Name && list[i].Name != "重复值")
{
list[j].Name = "重复值";
}
}
}
for (int i = 0; i < list.Count; i++)
{
if (list[i].Name != "重复值")
{
TypeAndName single = new TypeAndName();
single.Name = list[i].Name;
single.Type = list[i].Type;
resultList.Add(single);
}
}
return resultList;
}