Type.GetTypeArray(Object[]) Type.GetTypeArray(Object[]) Type.GetTypeArray(Object[]) Type.GetTypeArray(Object[]) Method

定義

取得指定陣列中物件的類型。Gets the types of the objects in the specified array.

public:
 static cli::array <Type ^> ^ GetTypeArray(cli::array <System::Object ^> ^ args);
public static Type[] GetTypeArray (object[] args);
static member GetTypeArray : obj[] -> Type[]
Public Shared Function GetTypeArray (args As Object()) As Type()

參數

args
Object[]

要決定類型之物件的陣列。An array of objects whose types to determine.

傳回

Type[]

Type 物件的陣列,代表 args 中對應項目的類型。An array of Type objects representing the types of the corresponding elements in args.

例外狀況

argsnullargs is null.

-或--or- args 的其中一或多個項目為 nullOne or more of the elements in args is null.

叫用了類別初始設定式,並至少有一個會擲回例外狀況。The class initializers are invoked and at least one throws an exception.

範例

下列程式碼範例示範如何使用GetTypeArray列出陣列的項目類型的方法。The following code example demonstrates how to use the GetTypeArray method to list the types of the elements of an array.

array<Object^>^myObject = gcnew array<Object^>(3);
myObject[ 0 ] = 66;
myObject[ 1 ] = "puri";
myObject[ 2 ] = 33.33;

// Get the array of 'Type' class objects.
array<Type^>^myTypeArray = Type::GetTypeArray( myObject );
Console::WriteLine( "Full names of the 'Type' objects in the array are:" );
for ( int h = 0; h < myTypeArray->Length; h++ )
{
   Console::WriteLine( myTypeArray[ h ]->FullName );

}
Object[] myObject = new Object[3];
myObject[0] = 66;
myObject[1] = "puri";
myObject[2] = 33.33;
// Get the array of 'Type' class objects.
Type[] myTypeArray = Type.GetTypeArray(myObject);
Console.WriteLine("Full names of the 'Type' objects in the array are:");
for(int h = 0; h < myTypeArray.Length ; h++)
{
    Console.WriteLine(myTypeArray[h].FullName);
}
Dim myObject(2) As Object
myObject(0) = 66
myObject(1) = "puri"
myObject(2) = 33.33
' Get the array of 'Type' class objects.
Dim myTypeArray As Type() = Type.GetTypeArray(myObject)
Console.WriteLine("Full names of the 'Type' objects in the array are:")
Dim h As Integer
For h = 0 To myTypeArray.Length - 1
   Console.WriteLine(myTypeArray(h).FullName)
Next h

適用於