linq Select与SelectMany的区别
2023-11-15
Select
string[] text = { "Albert was here", "Burke slept late", "Connor is happy" };
var tokens = text.Select(s => s.Split(' '));
foreach (string[] line in tokens)
{
foreach (string token in line)
{
Console.Write("{0}.", token);
}
}
SelectMany
foreach (string token in tokens)
{
Console.Write("{0}.", token);
}