我在弄清楚如何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)”的类型参数。尝试明确指定类型参数。
明确指定类型参数的正确方法是什么?