Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
3000 語の文字列配列があります。LINQ を使用して配列を 10 個のグループに分割するにはどうすればよいですか。10 項目ごとに 1 つの変数に格納する必要があります。結果は、グループを含む新しい配列になります。
単語が単一のスペースで区切られていると仮定すると、次のように分割して再グループ化できます。
var res = longWord .Split(' '). .Select((s, i) => new { Str = s, Index = i }) .GroupBy(p => p.Index / 10) .Select(g => string.Join(" ", g.Select(v => v.Str)));