Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };
int[] numbersB = { 1, 3, 5, 7, 8 };

var pairs =
    from a in numbersA
    from b in numbersB
    where a < b
    select new { a, b };
Posted
Updated 9-Oct-15 1:04am
v3

1 solution

Do you mean:
C#
var pairs = numbersA.SelectMany( a => numbersB.Select( b => new {A = a, B = b})).Where(x => x.A < x.B);
 
Share this answer
 
Comments
George Swan 10-Oct-15 3:05am    
This is an excellent example of the SelectMany extension. I didn't know it was so versatile. 5 from me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900