BasicKnowledgeCSharp/LessonsAndTasks/Lesson 31 - Вывод двумерного массива/Program.cs
Dvurechensky bf6a7c2b4e 1.1
2025-05-12 02:48:54 +03:00

55 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Author: Nikolay Dvurechensky
* Site: https://www.dvurechensky.pro/
* Gmail: dvurechenskysoft@gmail.com
* Last Updated: 12 мая 2025 02:47:11
* Version: 1.0.3
*/
using System;
/*
* Вывод двумерного массива
*/
class Program
{
static void Main()
{
int[,] myArray = new int[,]
{
{1, 2, 3, 4 },
{5, 6, 7, 8 },
{9, 10, 11, 12 },
{13, 14, 15, 16 }
};
foreach (var item in myArray)
{
Console.WriteLine(item);
}
Console.WriteLine();
//Число измерений массива - одномерный, двумерный и тд.
Console.WriteLine(myArray.Rank);
Console.WriteLine();
//Суммарно число элементов в массиве.
Console.WriteLine(myArray.Length);
Console.WriteLine();
//Количество элементов в конкретном измерении (измеряется с 0(1))
Console.WriteLine(myArray.GetLength(1));
Console.WriteLine();
for (int y = 0; y < myArray.GetLength(0); y++)
{
for (int x = 0; x < myArray.GetLength(1); x++)
{
Console.Write(myArray[y, x] + "\t");
}
Console.WriteLine();
}
Console.WriteLine();
Console.ReadKey();
}
}