1

It's probably something obvious that I'm not seeing. My chunk of code is

static IEnumerable<char[][]> InnerGridgs(string[] outer, int height, int width)
{
    if((outer.Length | outer[0].Length) == 0)
        yield break;
    char[][] G = StringArrayToCharMatrix(outer);
    for(int i = 0, n = G.Length - height; i < n; ++i)
    {
        for(int j = 0, m = G[0].Length; j < m; ++j)
        {
            char[][] inner = new char[height][width];
            for(int ii = 0; ii < height; ++ii)
            {
                for(int jj = 0; jj < width; ++jj)
                {
                    inner[ii][jj] = G[i + ii][j + jj];
                }
            }
            yield return inner;
        }
    }
}

and the compiler is complaining about the line

char[][] inner = new char[height][width];

saying

Cannot implicitly convert type char' tochar[][]'

user7127000
  • 3,143
  • 6
  • 24
  • 41
  • https://stackoverflow.com/questions/12567329/multidimensional-array-vs –  Feb 07 '17 at 16:01
  • You cannot initialize a jagged array that way. You have to initialize the outter array first, then each of the inner arrays. That or switch to 2D arrays. Also the compiler error I get from you code is "CS0178 Invalid rank specifier: expected ',' or ']" – juharr Feb 07 '17 at 16:01
  • @Amy Good find. The first line of code in the dup is exactly the problem! Most fitting solution would be [this answer](http://stackoverflow.com/a/12567404/993547). – Patrick Hofman Feb 07 '17 at 16:02

0 Answers0