-3

I'm trying to store all my answers to a question in a two-dimensional array. But I'm getting the problem: "An array initializer of length '13' is expected".

I've tried changing the syntax but haven't found any way that it works.

string[,] answerCombinations; 
            answerCombinations = new string[,]
            {
                {
                    "kanes",
                    "skean",
                    "snake",
                    "sneak",
                    "kane",
                    "kens",
                    "sank",
                    "kaes",
                    "keas",
                    "sake",
                    "anes",
                    "sane",
                    "naes"

                }, 
                {
                    "more",
                    "omer",
                    "mor",
                    "rem",
                    "rom",
                    "ore",
                    "roe",
                    "emo"
                }


            };
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
  • I suggest you have a look at [this question](https://stackoverflow.com/questions/597720/what-are-the-differences-between-a-multidimensional-array-and-an-array-of-arrays). – StackLloyd Jul 09 '19 at 14:45

1 Answers1

2

2d array defined with [,] should have the same number of columns. You can do this instead:

string[][] answerCombinations; 
            answerCombinations = new string[][]
            {
                new string[]{
                    "kanes",
                    "skean",
                    "snake",
                    "sneak",
                    "kane",
                    "kens",
                    "sank",
                    "kaes",
                    "keas",
                    "sake",
                    "anes",
                    "sane",
                    "naes"

                }, 
                new string[]{
                    "more",
                    "omer",
                    "mor",
                    "rem",
                    "rom",
                    "ore",
                    "roe",
                    "emo"
                }


            };
Sohaib Jundi
  • 1,576
  • 2
  • 7
  • 15