Created
July 18, 2022 14:06
-
-
Save bharathmuddada/7d9b52401260e0c94ec2eda015784e8e to your computer and use it in GitHub Desktop.
Accessing elements from jagged Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JaggedArraySample | |
{ | |
public static void Main(String[] args) | |
{ | |
var jaggedArray = new int[][] { | |
new int[] {1,2,3 }, | |
new int[] {4,5,6,7 }, | |
new int[] {8,9,10,11,12} | |
}; | |
//Accessing elements of rectangular or 2d array | |
for (int i = 0; i < jaggedArray.Length; i++) | |
{ | |
for (int j = 0; j < jaggedArray[i].Length; j++) | |
{ | |
Console.WriteLine(jaggedArray[i][j]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment