먼저 들쭉날쭉한 배열을 설정합니다.
int[][] arr = new int[][] {
new int[] {
0,
0
}, new int[] {
1,
2
},
new int[] {
2,
4
}, new int[] {
3,
6
}, new int[] {
4,
8
}
}; 이제 GetLowerBound(), GetUpperBound() 및 Rank 속성을 사용하여 다음 코드와 같이 배열의 길이와 순위를 가져옵니다. -
예시
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