Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent lambda syntax for linq query

Tags:

c#

linq

I am having a mind-freeze here, but I cant seem to find the equivalent lambda syntax for -

string[] a = {"a","b","c"}; 
string[] b = {"1","2","3"}; 

var x = from a1 in a
        from b1 in b
        select new{a1, b1};
like image 963
ilias Avatar asked Aug 24 '26 14:08

ilias


2 Answers

var x = a.SelectMany(a1=>b.Select(b1=>new {a1,b1}));
like image 199
Alan Avatar answered Aug 26 '26 03:08

Alan


ReSharper says:

var x = a.SelectMany(a1 => b, (a1, b1) => new { a1, b1 });
like image 33
Julien Lebosquain Avatar answered Aug 26 '26 04:08

Julien Lebosquain