Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _2DArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- Array array = new Array();
- array.ShowInfo();
- }
- }
- class Array
- {
- int[,] numbers = new int[,] { { 1, 2, 3}, {4, 5, 6 } };
- public void ShowInfo()
- {
- // ПЛОХОЙ КОД ИЗ-ЗА ДВОЙНОЙ ВЛОЖЕННОСТИ FOR
- //for (int i = 0; i < numbers.GetLength(0); i++)
- //{
- // for (int j = 0; j < numbers.GetLength(1); j++)
- // {
- // Console.Write($"{numbers[i,j]} ");
- // }
- //}
- ShowArray();
- }
- private void ShowArray()
- {
- for (int i = 0; i < numbers.GetLength(0); i++)
- {
- ShowLine(i);
- Console.WriteLine();
- }
- }
- private void ShowLine(int line)
- {
- for (int i = 0; i < numbers.GetLength(1); i++)
- {
- Console.Write($"{numbers[line,i]} ");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment