Created
July 18, 2022 13:55
-
-
Save bharathmuddada/0e2b87089749f5720d74c259ca3eb530 to your computer and use it in GitHub Desktop.
Access elements from rectangular 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 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