C#LINQSelectMany
Join

SelectManyLINQ

First

ネストしたコレクションを平坦化します。

構文

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