5
リストの番号付きグループを作成しようとしています。 たとえば、このLINQクエリは、私がSelectManyでインデックスを使用するLINQ
(from word in "The quick brown fox jumps over the lazy dog" .Split()
group word by word.Length into w
select w)
.Select((value, index) => new { i = index + 1, value })
.SelectMany(
sm => sm.value,
(sm, s) => new { sm.i, s})
1 The
1 fox
1 the
1 dog
2 quick
2 brown
2 jumps
3 over
3 lazy
欲しいものを与えます。しかし、私はこのクエリを最適化することを決定した:我々はそれがSelectManyの第四過負荷にインデックスを所有している場合SelectManyインデックスに外部使う必要があるのはなぜ? そして、このオーバーロードを次の方法で使用しようとしましたが、解決策が表示されません。
SelectMany
の
(from word in "The quick brown fox jumps over the lazy dog".Split()
group word by word.Length into w
select w)
.SelectMany(
(source, index) => ??????,
(msource, coll) => ??????)
グレート!期待以上に簡単です。 –