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。

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



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Type.GetArrayRank メソッド」の関連用語

Type.GetArrayRank メソッドのお隣キーワード
検索ランキング

   

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



Type.GetArrayRank メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS