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
Post a Comment