---
title: "Two dimensional C# Array initialized with 2 other arrays"  
description: "Two dimensional C# Array initialized with 2 other arrays"  
author: "Anonymous User"  
published: 2014-08-14  
updated: 2014-08-14  
canonical: https://www.mindstick.com/forum/2032/two-dimensional-c-sharp-array-initialized-with-2-other-arrays  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Two dimensional C# Array initialized with 2 other arrays

I'm a [bit](https://www.mindstick.com/forum/33411/how-we-tell-programmatically-if-i-m-running-in-64-bit-jvm-or-32-bit-jvm) new to C# and I don't understand how to make this work:

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) [static](https://www.mindstick.com/articles/12098/the-static-keyword-the-static-methods) [readonly](https://www.mindstick.com/forum/1419/how-can-i-make-the-wpf-datagrid-cells-readonly) [Unit](https://www.mindstick.com/articles/44359/store-your-valuable-items-in-a-mini-storage-unit)[,] UNIT_TYPES = new Unit[,]{LENGTH_UNITS, ANGLE_UNITS};

private static readonly Unit[] LENGTH_UNITS = new Unit[3]{Unit.Millimeters, Unit.Inches, Unit.Centimeters};

private static readonly Unit[] ANGLE_UNITS = new Unit[2]{Unit.Degrees, Unit.Radians};

I'm getting the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) "A [nested](https://www.mindstick.com/forum/45/itemcommand-event-in-nested-repeater-and-listview) [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) initializer was expected" on the UNIT_TYPES variable. It seems to not [except](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) the fact that LENGTH_UNITS and ANGLE_UNITS will be ready at [compile](https://www.mindstick.com/forum/2316/how-to-views-compile-in-mvc) time. What's the best way to rewrite this?

Thanks!

## Replies

### Reply by Pravesh Singh

Hi Goti, \

You're trying to initialize a rectangular array

```
int[,] Position = { {2 , 3}, {4 , 5}, {6 , 7} };this like three array inside a array Eq:     int[] IN0 = { 2,3 };     int[] IN1 = { 4,5 };     int[] IN2 = { 6,7 };``     int[][] Final = {
IN0, IN1, IN2 };
```

int[,] = the way of create Rect some as grids. int[][] = the way of accessing grid or 2d images


---

Original Source: https://www.mindstick.com/forum/2032/two-dimensional-c-sharp-array-initialized-with-2-other-arrays

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
