I'm trying to remove example duplicate entries from this 2D List.
I've already tried using the .Distinct().ToList()
method as highlighted in answers for 1D Lists but it doesn't seem to work for me here.
My code so far:
List<List<float>> xyvertices = new List<List<float>>();
xyvertices.Add(new List<float>());
yvertices[0].Add(2);
xyvertices[0].Add(4);
for (int a = 1; a < 6; a++)
{
xyvertices.Add(new List<float>());
xyvertices[a].Add(a+1);
xyvertices[a].Add(a+3);
}
xyvertices = xyvertices.Distinct().ToList();
Console.WriteLine("count:" + xyvertices.Count + "\n");
for (int i =0; i<xyvertices.Count; i++)
{
Console.WriteLine(xyvertices[i][0]);
Console.WriteLine(xyvertices[i][1]);
Console.WriteLine();
}
Console.ReadLine();
The above code runs but nothing changes.
How can I make this work? Thanks
>`, you must implement [IEqualityComparer](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iequalitycomparer-1?view=netframework-4.8)
– styx Jul 14 '19 at 07:28