Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created July 18, 2022 14:06
Show Gist options
  • Save bharathmuddada/7d9b52401260e0c94ec2eda015784e8e to your computer and use it in GitHub Desktop.
Save bharathmuddada/7d9b52401260e0c94ec2eda015784e8e to your computer and use it in GitHub Desktop.
Accessing elements from jagged Array
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