BasicKnowledgeCSharp/LessonsAndTasks/Lesson 31 - Вывод двумерного массива/Program.cs
Dvurechensky 058c8f2679 1.0
Main
2024-10-05 09:59:53 +03:00

47 lines
1.2 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.

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();
}
}