Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp9
- {
- class Program
- {
- static void Main(string[] args)
- {
- DrawGrid(5,5);
- }
- static void DrawGrid(int columnCount, int rowCount)
- {
- int[,] twoDimensionArray = new int[columnCount, rowCount];
- // Initialise 2d array
- for (int i = 0; i < columnCount; i++)
- {
- for (int j = 0; j < rowCount; j++)
- {
- twoDimensionArray[i, j] = i % 2;
- }
- }
- // Print 2d array
- for (int i = 0; i < columnCount; i++)
- {
- for (int j = 0; j < columnCount; j++)
- {
- Console.Write($"[ {twoDimensionArray[i, j]} ]");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment