---
title: "How do I declare a Jagged array of 2 dimensions?"  
description: "How do I declare a Jagged array of 2 dimensions?"  
author: "Anonymous User"  
published: 2013-09-04  
updated: 2013-09-04  
canonical: https://www.mindstick.com/forum/1446/how-do-i-declare-a-jagged-array-of-2-dimensions  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How do I declare a Jagged array of 2 dimensions?

I m [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to declare a 2D [dynamic](https://www.mindstick.com/blog/11080/features-of-java-dynamic-complied-and-interpreted) [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) below is my code:

var marray= new[,]

{

{

"1",

"[Module](https://www.mindstick.com/blog/11796/prestashop-one-page-checkout-module-make-checkout-faster) 1.1",

"Module 1.2",

" Module 1.3",

"Module 1.4",

"Module 1.5"

},

{

"2",

"Module 2.1"

}

};

I am [getting error](https://www.mindstick.com/forum/159638/getting-error-microsoft-office-interop-outlook-doesn-t-work) on [second](https://answers.mindstick.com/qa/41761/how-did-the-second-industrial-revolution-influence-women-s-roles-in-society) value "An array initializer of '6' is expected". I can understant it is expecting 2nd to be having 6 [values](https://www.mindstick.com/forum/327/sum-textbox-values) but I need it to be dynamic of any length. I dont know much about array so cannot [resolve](https://www.mindstick.com/forum/159427/windows-app-dll-not-found-resolve-library-issue) it. Can you please guide. Thanks.

## Replies

### Reply by Sumit Kesarwani

Hi Pravesh,\

You want a ragged array rather than a straight multi-dimensional array because your sub-array sizes are not the same.

Declare as

var marray= new[][]

rather than

var marray= new[,]


---

Original Source: https://www.mindstick.com/forum/1446/how-do-i-declare-a-jagged-array-of-2-dimensions

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
