2
Answers

Two Dimensional Array Element Limit?

Ask a question
I'm trying to load a 2 dimensional array with the first dimension containing the characters 1-12 and the second the characters 1-31.
    string[,] holiDays = new string[,] {{ "1","2","3","4","5","6","7","8",
            "9","10","11","12" },{ "1","2","3","4","5","6","7","8","9","10",
                "11","12","13","14","15","16","17","18","19","20","21","22",
                "23","24","25","26","27","28","29","30","31" }};
I get the folowing error:
Invalid rank specifier: expected ',' or ']'  (CS0178)

If I trim each of the array dimension values to seven, the error goes away.   As soon as I add the eighth value in either dimension, the error returns.

For example, this gets no error:
    string[,] holiDay2 = new string[,] {{ "1","2","3","4","5","6","7"},
{ "1","2","3","4","5","6","7"}};

These get the error:
    string[,] holiDay2 = new string[,] {{ "1","2","3","4","5","6","7","8"},
{ "1","2","3","4","5","6","7"}};

    string[,] holiDay2 = new string[,] {{ "1","2","3","4","5","6","7"},
{ "1","2","3","4","5","6","7","8"}};

Any ideas on this?

Answers (2)