

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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
- what is the simplest way to print a java array
- 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
- Multi Dimensional Arrays in Javascript
- Multi-dimensional lists in Python
- 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
Advertisements