How is it possible (in my case in C#) to compare an element in a list to all other elements in the list, but (of course) NOT to itself - and to do this for all elements?
Example:
List <sometype> A = new List<sometype> ();
Foreach (sometype e_1 in A)
{
Foreach (sometype e_2 in A)
{
// compare e_2 to the other elements in A except e_1
}
}
That means that I must exclude 'e_1' in the 2nd loop, but how can I do this? Whe I use
Foreach (sometype e_2 in A.Skip() )in the 2nd loop I hav to know the index of 'e_1'. Wehre I can find this easyly? Or is there another way?
Thx a lot :-)
Stupid solution: use for by i and for by j where i != j
If you need just unique items, use HashSet, hashSet.Add will return false if it already have the item.