GetLength는 Array의 지정된 차원에 있는 요소 수를 나타내는 32비트 정수를 가져옵니다.
먼저 배열을 설정합니다.
int[,] arr = new int[20, 30];
배열의 지정된 차원에 대해 -
와 같이 GetLength() 메서드에서 인덱스를 설정합니다.Arr.GetLength(1);
예시
using System;
class Program {
static void Main() {
int[,] arr = new int[20, 30];
int len = arr.GetLength(1);
Console.WriteLine(len);
}
} 출력
30