PART I
C h a p t e r 1 9 :
L I N Q
573
PART IPART I
// Execute the query and display the results.
foreach(var t in byHow) {
Console.WriteLine("{0} transportation includes:", t.How);
foreach(var m in t.Tlist)
Console.WriteLine(" " + m.Name);
Console.WriteLine();
}
}
}
The output is shown here:
Air transportation includes:
Balloon
Jet
Biplane
Sea transportation includes:
Boat
Canoe
Cargo Ship
Land transportation includes:
Bicycle
Car
Train
The key part of the program is, of course, the query, which is shown here:
var byHow = from how in travelTypes
join trans in transports
on how equals trans.How
into lst
select new { How = how, Tlist = lst };
Here is how it works. The
Do'stlaringiz bilan baham: |