I have a list which has double array whose items are geocordinates,this list has duplicate elements which i need to remove to preserve only unique values
this is what i have tried
IList<double[]> result = new List<double[]>(); /list declaration
// result gets value from a soap call
for (int i = 0; i < result.Count; i++)
{
for (int j = 0; j < result.Count; j++)
{
if (result[i][0].ToString() == result[j][0].ToString() || result[i][1].ToString() == result[j][1].ToString())
{
result.Remove(result[j]);
}
}
}
result - my list which has redundant arrays
basically, i need to remove all the arrays inside the list which has same values(x and y geocordinates)
still i have some elements in the list which gets duplicated, can anyone improve my solution please ? would be great help
||to&&double[], you can define coordinates as Point class. InPointclass, you can override theToEqualsmethod to check the duplicate.System.WindowsorSystem.Drawing, I would suggest to write a new class with decimal and decimal as X and Y respectively. With this approach, you will have full control over it to override ToEquals method.