I have to find out how to call Parallel.ForEach with a 2D little problem Getting the array of stars:
string [,] board = new string [,] {{"A", "B", "C", "D", "E"} , "I", "J"}, {"of", "", "" "," "", "", "n", "o"}, "ji", "h" "," L "," 2 "," 3 "," 4 "}}; Parallel.ForEach (board, line => (for int i = 0; i & lt; line.lannel; ++ I) {// Find all valid sequences}}); If I do not explicitly specify this way, then I The error receives:
The method for the argument can not be estimated using 'System.Threading.Tasks.Parallel. ForEach (System.Collections.Generic.IEnumerable, System.Action)' Try specifying type arguments explicitly.
What is the correct way to specify type arguments?
< Div class = "post-text" itemprop = "Text">
The problem for you is that 2-dimensional arrays IEnumerable & lt; One-dimensional-array & gt; . (It implements IEnumerable , but it's a IEnumerable string which "flattens" the array.) You can do two things:
- Change the
[,] to a linear array-of-arrays, string [] []. -
Implement your extension method, which repeats with a two-dimensional array and assigns it to a
IEnumerable & lt; One-dimensional-array & gt;.
Comments
Post a Comment