Hi All,
I have written a program which contains a class 'Numbers' which can hold a set five numbers. I then create 2 List<Numbers> instances which generate a random numbers. I then loop through one list and try to use linq to find if the list has an identical set of numbers.
var foundLine = LineList.Find(a => (a.Ball1 == line.NumberOne || a.Ball1 == line.NumberTwo || a.Ball1 == line.NumberThree || a.Ball1 == line.NumberFour || a.Ball1 == line.NumberFive) && (a.Ball2 == line.NumberOne || a.Ball2 == line.NumberTwo || a.Ball2 == line.NumberThree || a.Ball2 == line.NumberFour || a.Ball2 == line.NumberFive) && (a.Ball3 == line.NumberOne || a.Ball3 == line.NumberTwo || a.Ball3 == line.NumberThree || a.Ball3 == line.NumberFour || a.Ball3 == line.NumberFive) && (a.Ball4 == line.NumberOne || a.Ball4 == line.NumberTwo || a.Ball4 == line.NumberThree || a.Ball4 == line.NumberFour || a.Ball4 == line.NumberFive) && (a.Ball5 == line.NumberOne || a.Ball5 == line.NumberTwo || a.Ball5 == line.NumberThree || a.Ball5 == line.NumberFour || a.Ball5 == line.NumberFive));
For testing I hard coded the two list so:
LineList would contain (1,2,3,4,5), (4,3,2,7,1),(222,122,1,33,44).
line would contain (1,2,3,4,66),(22,22,33,11,346),(23,33,66,88,44)
So from looping though line. I should expect to see no match with the piece of code above, however im getting the nearest thing, in this case (1,2,3,4,66) corresponding to (1,2,3,4,5).
Does anybody know what im doing wrong, or even a better way of comparing list as im comparing against as many as 40k of elements.
Thanks