可能重复:
Avoid duplicates
你好, 我想避免数组中的重复条目.....(在c#中)
答案 0 :(得分:1)
使用不同的方法:
public static void DistinctExample()
{
string[] names = new string[] { "Peter", "Paul", "Mary",
"Peter", "Paul", "Mary", "Janet" };
var q = (from s in names
select s).Distinct();
foreach (var name in q) {
Console.WriteLine(name);
}
Console.ReadLine();
}
答案 1 :(得分:0)