SelectMany

string[] presidents = {
"Adams""Arthur""Buchanan""Bush""Carter""Cleveland",
"Clinton""Coolidge""Eisenhower""Fillmore""Ford""Garfield",
"Grant""Harding""Harrison""Hayes""Hoover""Jackson",
"Jefferson""Johnson""Kennedy""Lincoln""Madison""McKinley",
"Monroe""Nixon""Pierce""Polk""Reagan""Roosevelt""Taft",
"Taylor""Truman""Tyler""Van Buren""Washington""Wilson"}
;

IEnumerable
<char> chars = presidents.SelectMany(p => p.ToArray());
Employee[] employees = Employee.GetEmployeesArray();
EmployeeOptionEntry[] empOptions 
= EmployeeOptionEntry.GetEmployeeOptionEntries();

var employeeOptions 
= employees
                      .SelectMany(e 
=> empOptions
                                       .Where(eo 
=> eo.id == e.id)
                                       .Select(eo 
=> new {
                                                           id 
= eo.id,
                                               optionsCount 
= eo.optionsCount }
));

foreach (var item in employeeOptions)
   Console.WriteLine(item);
原文地址:https://www.cnblogs.com/anders06/p/1516805.html