Array.Rank 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
의 순위(차원 수)를 Array가져옵니다. 예를 들어 1차원 배열은 1을 반환하고 2차원 배열은 2를 반환합니다.
public:
property int Rank { int get(); };
public int Rank { get; }
member this.Rank : int
Public ReadOnly Property Rank As Integer
속성 값
의 순위(차원 수)입니다 Array.
예제
다음 예제에서는 1차원 배열, 2차원 배열 및 들쭉날쭉한 배열을 초기화하고 각 배열의 속성을 검색합니다 Rank .
using System;
public class Example
{
public static void Main()
{
int[] array1 = new int[10];
int[,] array2= new int[10,3];
int[][] array3 = new int[10][];
Console.WriteLine("{0}: {1} dimension(s)",
array1.ToString(), array1.Rank);
Console.WriteLine("{0}: {1} dimension(s)",
array2.ToString(), array2.Rank);
Console.WriteLine("{0}: {1} dimension(s)",
array3.ToString(), array3.Rank);
}
}
// The example displays the following output:
// System.Int32[]: 1 dimension(s)
// System.Int32[,]: 2 dimension(s)
// System.Int32[][]: 1 dimension(s)
let array1 = Array.zeroCreate<int> 10
let array2 = Array2D.zeroCreate<int> 10 3
let array3 = Array.zeroCreate<int[]> 10
printfn $"{array1}: {array1.Rank} dimension(s)"
printfn $"{array2}: {array2.Rank} dimension(s)"
printfn $"{array3}: {array3.Rank} dimension(s)"
// The example displays the following output:
// System.Int32[]: 1 dimension(s)
// System.Int32[,]: 2 dimension(s)
// System.Int32[][]: 1 dimension(s)
Module Example
Public Sub Main()
Dim array1(9) As Integer
Dim array2(9,2) As Integer
Dim array3(9)() As Integer
Console.WriteLine("{0}: {1} dimension(s)",
array1.ToString(), array1.Rank)
Console.WriteLine("{0}: {1} dimension(s)",
array2.ToString(), array2.Rank)
Console.WriteLine("{0}: {1} dimension(s)",
array3.ToString(), array3.Rank)
End Sub
End Module
' The example displays the following output:
' System.Int32[]: 1 dimension(s)
' System.Int32[,]: 2 dimension(s)
' System.Int32[][]: 1 dimension(s)
설명
예를 들어 다음 코드는 값이 3인 속성을 사용하여 Rank 3차원 배열을 만듭니다.
Dim TDArray(0,0,0) As Integer
int[,,] TDArray = new int[1,1,1];
가변 배열(배열 배열)은 1차원 배열입니다. 속성 Rank 의 값은 1입니다.
이 속성의 값을 검색하는 것은 O(1) 작업입니다.