SelectManyLINQ
중첩 컬렉션을 평탄화합니다.
문법
source.SelectMany(selector)예제
아래 값을 입력하면 예제에 즉시 반영됩니다.
var→sentences→new→words→SelectMany→Split→ToList→Console→WriteLine→string→Hello→World→Foo→Bar→var sentences = new[] { "Hello World", "Foo Bar" };
var words = sentences.SelectMany(s => s.Split(' ')).ToList();
Console.WriteLine(string.Join(", ", words));
// Hello, World, Foo, Bar