Distinct List in List of Lists
1,1].Distinct() returns [1]
[[1],[1]].Distinct() returns [[1],[1]]
what to do ?
2 Replies
I need this only for numeric values
public class ListComparer : IEqualityComparer<List<long>>
{
public bool Equals(List<long> x, List<long> y)
{
if (x.Count != y.Count)
return false;
for (int i = 0; i < x.Count; i++)
if (x[i] != y[i]) return false;
return true;
}
public int GetHashCode(List<long> x) => x.Count;
}
How to do this for generic real number type using numeric types
?
Enumerable.SequenceEqual Method (System.Linq)
Determines whether two sequences are equal according to an equality comparer.