c# - How do I declare a Jagged array of 2 dimensions? -


i m trying declare 2d dynamic array below 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 getting error on second value "an array initializer of '6' expected". can understant expecting 2nd having 6 values need dynamic of length. dont know array cannot resolve it. can please guide. thanks

you're receiving compile error because sub-array sizes not equivalent. you'll either need implement using jagged arrays mitch wheat suggests or ensure elements in sub-array have same number of elements.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -