1

まず、これがこの質問の複製であることは知っていますが、そこにリストされている解決策をうまく機能させることができません。MatchCollection は IEnumerable Parallel.ForEach の使用を実装していないため、OfType() が必要であることを理解しています...私が間違っていることは何ですか? これが私のセットアップです:

MatchCollection startMatches = Regex.Matches(tempRTB.Text, startPattern);

System.Threading.Tasks.Parallel.ForEach(startMatches.OfType<Match>, m =>
{
    // do stuff with m
});

そして、ここに私が得るコンパイルエラーがあります:

Error   11  The type arguments for method 'System.Threading.Tasks.Parallel.ForEach<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Action<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
4

1 に答える 1