먼저 들쭉날쭉한 배열을 선언하고 초기화합니다.
int[][] arr = new int[][] {
new int[] {
0,
0
}, new int[] {
1,
2
},
new int[] {
2,
4
}, new int[] {
3,
6
}, new int[] {
4,
8
}
}; 이제 length 속성을 사용하여 길이를 가져옵니다.
arr.Length
다음은 완전한 코드입니다 -
예시
using System;
public class Program {
public static void Main() {
int[][] arr = new int[][]{new int[]{0,0},new int[]{1,2}, new int[]{2,4},new int[]{ 3, 6 }, new int[]{ 4, 8 } };
// Length
Console.WriteLine("Length:"+arr.Length);
Console.WriteLine("Upper Bound: {0}",arr.GetUpperBound(0).ToString());
Console.WriteLine("Lower Bound: {0}",arr.GetLowerBound(0).ToString());
Console.WriteLine("Dimensions of Array : " + arr.Rank);
}
} 출력
Length:5 Upper Bound: 4 Lower Bound: 0 Dimensions of Array : 1