C#Linq Distinct最近是否已停止工作? 几个月前,它现在的工作就像一个魅力,但事实并非如此。例如,当我尝试这样做时
Product[] products = { new Product { Name = "apple", Code = 9 },
new Product { Name = "orange", Code = 4 },
new Product { Name = "apple", Code = 9 },
new Product { Name = "lemon", Code = 12 } };
IEnumerable<Product> noduplicates =
products.Distinct();
foreach (var product in noduplicates)
Console.WriteLine(product.Name + " " + product.Code);
This code should produce the following output:
apple 9
orange 4
lemon 12
但它会产生以下输出: 苹果9 橙色4 苹果9 柠檬12