Hello,
My first post here. I have a problem that I'm sure is simple to solve but haven't yet managed to find a solution, hopefully one of you can help me. :-)
I have a list of int arrays which I have filled with numbers.
List<int[]> Numbers = new List<int[]>();
Numbers.Add(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 });
Numbers.Add(new int[] { 1, 2, 3, 4, 5, 6, 7, 8 });
Numbers.Add(new int[] { 65, 2, 7, 4, 2, 2, 4, 9 });
Numbers.Add(new int[] { 45, 2, 23, 4, 13, 6, 7, 8 });
Numbers.Add(new int[] { 1, 5, 876, 4, 5, 67, 7, 8 });
I then pass this list to a function that checks if there are any duplicate items in the Numbers List and removes them. But it doesn't work :-(
public void RemoveDuplicates(List<int[]> Nums)
for (int i = 0; i <= Nums.Count - 1; i++)
{
for (int n = 1; n <= Nums.Count-1; n++)
{
if (Nums[i].SequenceEqual(Nums[n]))
{
Nums.RemoveAt(n);
}
}
}
}
I'm sure it's a simple mistake I'm making but I can't work it out. Any ideas?
Thanks!