forum

Home / DeveloperSection / Forums / How do I declare a Jagged array of 2 dimensions?

How do I declare a Jagged array of 2 dimensions?

Anonymous User175204-Sep-2013

I m trying to declare a 2D dynamic array below is my code:

   var marray= new[,]

                        {

                            {

                                "1",

                                "Module 1.1",

                                "Module 1.2",

                                " Module 1.3",

                                "Module 1.4",

                                "Module 1.5"

                            },

                            {

                                "2",

                                "Module 2.1"                                   

                            }

                        };

I am getting error on second value "An array initializer of '6' is expected". I can understant it is expecting 2nd to be having 6 values but I need it to be dynamic of any length. I dont know much about array so cannot resolve it. Can you please guide. Thanks.


Updated on 04-Sep-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By