Created
June 5, 2018 21:45
-
-
Save janell-baxter/b3c306c81915d7d3dedbda398ace97fb to your computer and use it in GitHub Desktop.
Grid Array
This file contains 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
using System; | |
namespace GridArray | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
int[,] grid = new int[5, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 }, { 17, 18, 19, 20 } }; | |
int rows = grid.GetLength(0); | |
int columns = grid.GetLength(1); | |
for (int i = 0; i < rows; i++) | |
{ | |
for (int j = 0; j < columns; j++) | |
{ | |
Console.Write(string.Format("{0:D2} ", grid[i, j])); | |
} | |
Console.Write("\n\n"); | |
} | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment