Type.GetTypeArray(Object[]) 方法

定義

取得指定陣列中物件的類型。

C#
public static Type[] GetTypeArray (object[] args);

參數

args
Object[]

要決定類型之物件的陣列。

傳回

Type[]

Type 物件的陣列,代表 args 中對應項目的類型。

例外狀況

argsnull

-或- args 的其中一或多個項目為 null

叫用了類別初始設定式,並至少有一個會擲回例外狀況。

範例

下列程式碼範例示範如何使用 GetTypeArray 方法來列出陣列元素的類型。

C#
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);
}

適用於

產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1