_Type.GetArrayRankとは? わかりやすく解説

Type.GetArrayRank メソッド

Array の次元数を取得します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable Function
 GetArrayRank As Integer
public virtual int GetArrayRank ()
public:
virtual int GetArrayRank ()
public int GetArrayRank ()
public function GetArrayRank () : int

戻り値
現在の Type の次元数を保持している Int32。

例外例外
例外の種類条件

NotSupportedException

このメソッドの機能が基本クラスでサポートされないため、代わりに派生クラスで実装する必要があります。

ArgumentException

現在の Type が配列ではありません。

使用例使用例

配列の次元の数を表示する例を次に示します。

Imports System
Imports Microsoft.VisualBasic

Class MyArrayRankSample
    Public Shared Sub Main()
        Try
            Dim myArray(,,) As Integer
 = {{{12, 2, 35}, {300, 78, 33}}, {{92, 42, 135}, {30, 7, 3}}}
            Dim myType As Type = myArray.GetType()
            Console.WriteLine("Contents of myArray: {{{12,2,35}
,{300,78,33}},{{92,42,135},{30,7,3}}}")
            Console.WriteLine("myArray has {0} dimensions.",
 myType.GetArrayRank())
        Catch e As NotSupportedException
            Console.WriteLine("NotSupportedException raised.")
            Console.WriteLine(("Source: " + e.Source))
            Console.WriteLine(("Message: " + e.Message))
        Catch e As Exception
            Console.WriteLine("Exception raised.")
            Console.WriteLine(("Source: " + e.Source))
            Console.WriteLine(("Message: " + e.Message))
        End Try
    End Sub 'Main 
End Class 'MyArrayRankSample
using System;

class MyArrayRankSample
{
    public static void Main()
    {
        try
        {
            int[,,] myArray = new int[,,]
 {{{12,2,35},{300,78,33}},{{92,42,135},{30,7,3}}};
            Type myType = myArray.GetType();

            Console.WriteLine("Contents of myArray: {{{12,2,35},{300,78,33}}
,{{92,42,135},{30,7,3}}}");
            Console.WriteLine("myArray has {0} dimensions.", myType.GetArrayRank());
        }
        catch(NotSupportedException e)
        {
            Console.WriteLine("NotSupportedException raised.");
            Console.WriteLine("Source: " + e.Source);
            Console.WriteLine("Message: " + e.Message);
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception raised.");
            Console.WriteLine("Source: " + e.Source);
            Console.WriteLine("Message: " + e.Message);
        }      
    }
}
using namespace System;
int main()
{
   try
   {
      array<Int32, 3>^myArray = gcnew array<Int32,3>(3,4,5);
      Type^ myType = myArray->GetType();
      Console::WriteLine( "myArray has {0} dimensions.", myType->GetArrayRank()
 );
   }
   catch ( NotSupportedException^ e ) 
   {
      Console::WriteLine( "NotSupportedException raised." );
      Console::WriteLine( "Source: {0}", e->Source );
      Console::WriteLine( "Message: {0}", e->Message );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception raised." );
      Console::WriteLine( "Source: {0}", e->Source );
      Console::WriteLine( "Message: {0}", e->Message );
   }

}

import System.*;

class MyArrayRankSample
{
    public static void main(String[]
 args)
    {
        try {
            int myArray[, ,] = new int[,,]
 { { { 12, 2, 35 } ,
                { 300, 78, 33 } } , { { 92, 42, 135 } , { 30, 7, 3 } } };
            Type myType = myArray.GetType();

            Console.WriteLine("Contents of myArray: {{{12,2,35},{300,78,33}}
,"
                +"{{92,42,135},{30,7,3}}}");
            Console.WriteLine("myArray has {0} dimensions.",
                System.Convert.ToString(myType.GetArrayRank()));
        }
        catch (NotSupportedException e) {
            Console.WriteLine("NotSupportedException raised.");
            Console.WriteLine("Source: " + e.get_Source());
            Console.WriteLine("Message: " + e.get_Message());
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception raised.");
            Console.WriteLine("Source: " + e.get_Source());
            Console.WriteLine("Message: " + e.get_Message());
        }
    } //main
} //MyArrayRankSample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Type.GetArrayRank メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

COM オブジェクトに、Type.GetArrayRank メソッドへのバージョンに依存しないアクセスが用意されています。

このメソッドは、CLS に準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

int GetArrayRank ()
int GetArrayRank ()
int GetArrayRank ()
function GetArrayRank () : int

戻り値
現在の Type の次元数を保持している Int32。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「_Type.GetArrayRank」の関連用語

_Type.GetArrayRankのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



_Type.GetArrayRankのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS