
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What is the simplest multi-dimensional array in C#?
The simplest multi-dimensional array in C# is a two-dimensional array. A 2-dimensional array can be thought of as a table, which has x number of rows and y number of columns.
Multidimensional arrays may be initialized by specifying bracketed values for each row. The following array is with 4 rows and each row has 4 columns.
int [,] a = new int [4,4] { {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4, 5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9, 10, 11} /* initializers for row indexed by 2 */ {12, 13, 14, 15} /* initializers for row indexed by 3 */ };
The following is an example −
Example
using System; namespace Demo { class Program { static void Main(string[] args) { int[,] a = new int[5, 2] {{77,34}, {55,65}, {47,66}, {45,98}, {86,23} }; int i, j; for (i = 0; i < 5; i++) { for (j = 0; j < 2; j++) { Console.WriteLine(a[i,j]); } } Console.ReadKey(); } } }
- Related Articles
- What is a multi-dimensional array in C language?
- Multi-Dimensional Array in Javascript
- What are the differences between a multi-dimensional array and jagged array?
- Reduce a multi-dimensional array in Numpy
- Converting multi-dimensional array to string in JavaScript
- Greatest element in a Multi-Dimensional Array in JavaScript
- Merging duplicate values into multi-dimensional array in PHP
- How to access elements from multi-dimensional array in C#?
- Reduce a multi-dimensional array along given axis in Numpy
- Reduce a multi-dimensional array along axis 1 in Numpy
- Reduce a multi-dimensional array along negative axis in Numpy
- Reduce a multi-dimensional array and multiply elements in Numpy
- Reduce a multi-dimensional array and add elements in Numpy
- Multi Dimensional Arrays in Javascript
- Multi-dimensional lists in Python

Advertisements