【发布时间】:2010-07-20 00:56:33
【问题描述】:
我在弄清楚如何使用二维字符串数组调用 Parallel.ForEach 时遇到了一些麻烦:
string[,] board = new string[,]{
{"A", "B", "C", "D", "E" },
{"F", "G", "H", "I", "J"},
{"K", "L", "M", "N", "O"},
{"0", "1", "2", "3", "4"}};
Parallel.ForEach(board, row =>
{
for (int i = 0; i < row.Length; ++i)
{
// find all valid sequences
}
});
如果我没有明确指定类型,我会收到以下错误:
方法的类型参数 'System.Threading.Tasks.Parallel.ForEach(System.Collections.Generic.IEnumerable, System.Action)' 不能 从用法推断。尝试 指定类型参数 明确的。
明确指定类型参数的正确方法是什么?
【问题讨论】:
标签: c# multithreading concurrency parallel-extensions