4

リストが日付順に並べられているときに、リストに x オブジェクトが連続して含まれている場合に true を返す linq クエリのヘルプが必要です。

このように:

myList.InARow(x => x.Correct, 3)

プロパティ correct == true を持つ行が 3 つある場合、true を返します。

これを行う方法がわからない。

4

3 に答える 3

2

更新日:

myList.Aggregate(0,
    (result, x) => (result >= 3) ? result : (x.Correct ? result + 1 : 0),
    result => result >= 3);

一般化されたバージョン:

myList.Aggregate(0,
    (result, x) => (result >= length) ? result : (filter(x) ? result + 1 : 0),
    result => result >= length);
于 2013-04-29T16:16:44.393 に答える