onqkoie

Untitled

May 7th, 2020
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp9
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. DrawGrid(5,5);
  10. }
  11. static void DrawGrid(int columnCount, int rowCount)
  12. {
  13. int[,] twoDimensionArray = new int[columnCount, rowCount];
  14. // Initialise 2d array
  15. for (int i = 0; i < columnCount; i++)
  16. {
  17. for (int j = 0; j < rowCount; j++)
  18. {
  19. twoDimensionArray[i, j] = i % 2;
  20. }
  21. }
  22. // Print 2d array
  23. for (int i = 0; i < columnCount; i++)
  24. {
  25. for (int j = 0; j < columnCount; j++)
  26. {
  27. Console.Write($"[ {twoDimensionArray[i, j]} ]");
  28. }
  29. Console.WriteLine();
  30. }
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment