Venciity

[Jumpstart C#] two-dimesional array example 3

Feb 25th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace two_dimesional_array_2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[,] array = new int[3, 4];
  14.             for (int row = 0; row < array.GetLength(0); row++) // array.GetLength(0) - дължината на редовете
  15.             {
  16.                 for (int col = 0; col < array.GetLength(1); col++) // array.GetLength(1) - дължината на колоните
  17.                 {
  18.                     array[row, col] = row + col; // Задаване на стойност на елемент
  19.                 }
  20.             }
  21.  
  22.             var rank = array.Rank; // КОЛКО НАБРОЙ ИЗМЕРЕНИЯ ИМА МАСИВА
  23.             Console.WriteLine("БРОЙ ИЗМЕРЕНИЯ НА МАСИВА: {0}",rank);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment