C#의 Type.GetArrayRank() 메서드는 배열의 차원 수를 가져옵니다.
구문
public virtual int GetArrayRank ();
이제 Type.GetArrayRank() 메서드를 구현하는 예를 살펴보겠습니다. -
예시
using System;
public class Demo {
public static void Main(string[] args) {
Type type = typeof(int[,, ]);
int arrRank = type.GetArrayRank();
Console.WriteLine("Array Rank = {0}", arrRank);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Array Rank = 3
이제 Type.GetArrayRank() 메서드를 구현하는 또 다른 예를 살펴보겠습니다. -
예시
using System;
public class Demo {
public static void Main(string[] args) {
Type type = typeof(string[,,,,,,, ]);
Type type2 = typeof(string[,,,,,,, ]);
int arrRank = type.GetArrayRank();
Console.WriteLine("Array Rank = {0}", arrRank);
Console.WriteLine("Are both types equal? {0}", type.Equals(type2));
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Array Rank = 8 Are both types equal? True