Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created July 18, 2022 13:55
Show Gist options
  • Save bharathmuddada/0e2b87089749f5720d74c259ca3eb530 to your computer and use it in GitHub Desktop.
Save bharathmuddada/0e2b87089749f5720d74c259ca3eb530 to your computer and use it in GitHub Desktop.
Access elements from rectangular Array
public class RectangularArray
{
public static void Main(String[] args)
{
var rectangularArray = new int[,] {
{1,2,3 },
{4,5,6 },
{7,8,9}
};
//Accessing elements of rectangular or 2d array
for (int i = 0; i < rectangularArray.GetLength(0); i++)
{
for (int j = 0; j < rectangularArray.GetLength(1); j++)
{
Console.WriteLine(rectangularArray[i, j]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment