

- 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 type of elements of the jagged array in C#?
A jagged array is an array of arrays, and therefore its elements are reference types and are initialized to null.
Let us see how to work with Jagged array −
Declare a jagged array −
int [][] marks;
Now, let us initialize it, wherein marks is an arrays of 5 integers −
int[][] marks = new int[][]{new int[]{ 40,57 },new int[]{ 34,55 }, new int[]{ 23,44 },new int[]{ 56, 78 }, new int[]{ 66, 79 } };
Let us now see the complete example of jagged arrays in C# and learn how to implement it −
Example
using System; namespace MyApplication { class MyDemoClass { static void Main(string[] args) { int i, j; int[][] marks = new int[][] { new int[] { 90, 95 }, new int[] { 89, 94 }, new int[] { 78, 87 }, new int[] { 76, 68 }, new int[] { 98, 91 } }; for (i = 0; i < 5; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("marks[{0}][{1}] = {2}", i, j, marks[i][j]); } } Console.ReadKey(); } } }
Output
marks[0][0] = 90 marks[0][1] = 95 marks[1][0] = 89 marks[1][1] = 94 marks[2][0] = 78 marks[2][1] = 87 marks[3][0] = 76 marks[3][1] = 68 marks[4][0] = 98 marks[4][1] = 91
- Related Questions & Answers
- How to find the length of jagged array using a property?
- How to access elements from jagged array in C#?
- What are the differences between a multi-dimensional array and jagged array?
- Jagged Array in C#
- Jagged Array in Java
- How to find the length and rank of a jagged array in C#?
- What is the type of string literals in C/ C++?
- What is the return type of a Constructor in Java?
- What is the maximum length of each type of identifier in MySQL?
- Return the cumulative sum of array elements treating NaNs as zero but change the type of result in Python
- Grouping array of array on the basis of elements in JavaScript
- Get the number of elements of the Masked Array in Numpy
- What is the default type of a hexadecimal value in MySQL?
- What is the type of string literals in C and C++?
- What is the size of int, long type in C++ standard?
Advertisements