Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to enumerate for all permutations of two IEnumerables using linq

I could do this using loops, but is there a way to take two IEnumerables, enumerate through all possible permutations and select an object that contains the permutation? I feel like this 'should' be possible but am not really sure what operators to use.

Thanks James

like image 466
James Hay Avatar asked Apr 13 '10 13:04

James Hay


1 Answers

Are you talking about what is basically a cartesian join? You can do something like

var query = from item1 in enumerable1
            from item2 in enumerable2
            select new { Item1 = item1, Item2 = item2 }
like image 88
Anthony Pegram Avatar answered Nov 15 '22 03:11

Anthony Pegram