Type.GetTypeArray(Object[]) Método

Definição

Obtém os tipos dos objetos na matriz especificada.

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()

Parâmetros

args
Object[]

Uma matriz de objetos cujos tipos determinar.

Retornos

Type[]

Uma matriz de Type objetos que representa os tipos dos elementos correspondentes em args.

Exceções

args é null.

- ou -

Um ou mais dos elementos em args é null.

Os inicializadores de classe são invocados e pelo menos um gera uma exceção.

Exemplos

O exemplo de código a seguir demonstra como usar o GetTypeArray método para listar os tipos de elementos de uma matriz.

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);
}
let myObject = Array.zeroCreate<obj> 3
myObject[0] <- 66
myObject[1] <- "puri"
myObject[2] <- 33.33
// Get the array of 'Type' class objects.
let myTypeArray = Type.GetTypeArray myObject
printfn "Full names of the 'Type' objects in the array are:"
for h in myTypeArray do
    printfn $"{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

Aplica-se a