C# Distinct on IEnumerable with custom IEqualityComparer

后端 未结 3 1880
别跟我提以往
别跟我提以往 2020-12-07 18:41

Here\'s what I\'m trying to do. I\'m querying an XML file using LINQ to XML, which gives me an IEnumerable> object, where T is my \"Village\" class, filled

3条回答
  •  失恋的感觉
    2020-12-07 19:18

    Or change the line

    return alliances.Distinct(new AllianceComparer());
    

    to

    return alliances.Select(v => v.AllianceName).Distinct();
    

提交回复
热议问题