标签:http select for new line any Owner 一个 string
一个序列的每个元素投影, 将平展为一个序列。结果延迟执行。
PetOwner[] petOwners ={
new PetOwner { Name="Higa, Sidney",Pets = new List<string>{ "Scruffy", "Sam" } },
new PetOwner { Name="Ashkenazi, Ronen",Pets = new List<string>{ "Walker", "Sugar" } },
new PetOwner { Name="Price, Vernette",Pets = new List<string>{ "Scratches", "Diesel" } },
new PetOwner { Name="Hines, Patrick",Pets = new List<string>{ "Dusty" } } };
var query = petOwners.SelectMany(s => s.Pets, (s, section) => new
{
s.Name,
Pet = section,
});
foreach (var item in query)
{
Console.WriteLine(item.Name + ": " + item.Pet);
}
标签:http select for new line any Owner 一个 string
原文地址:https://www.cnblogs.com/wesson2019-blog/p/14684931.html