- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to access elements from multi-dimensional array in C#?
To acess element from the multi-dimensional array, just add the index for the element you want, for example −
a[2,1]
The above access element from 3rd row and 2nd column ie element 3 as shown below in out [3,4] array −
0 0 1 2 2 4 3 6
Let us see whatever we discussed and access element from a 2 dimensional array −
Example
using System; namespace Program { class Demo { static void Main(string[] args) { int[,] a = new int[4, 2] {{0,0}, {1,2}, {2,4}, {3,6} }; int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0},{1}] = {2}", i, j, a[i,j]); } } // accessing element Console.WriteLine(a[2,1]); Console.ReadKey(); } } }
- Related Articles
- How do we access elements from the two-dimensional array in C#?
- How to access elements from jagged array in C#?
- How to access elements from an array in C#?
- How to access elements from a rectangular array in C#?
- Reduce a multi-dimensional array and multiply elements in Numpy
- Reduce a multi-dimensional array and add elements in Numpy
- Multi-Dimensional Array in Javascript
- How to initialize multi-dimensional arrays in C#?
- How to define multi-dimensional arrays in C#?
- What is the simplest multi-dimensional array in C#?
- What is a multi-dimensional array in C language?
- How to define multi-dimensional arrays in C/C++?
- Converting multi-dimensional array to string in JavaScript
- Reduce a multi-dimensional array and add elements along negative axis in Numpy
- Reduce a multi-dimensional array and multiply elements along specific axis in Numpy

Advertisements