Compartir a través de


Type.GetTypeArray(Object[]) Método

Definición

Obtiene los tipos de los objetos de la 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[]

Matriz de objetos cuyos tipos se han de determinar.

Devoluciones

Type[]

Matriz de objetos Type que representa todos los tipos de los elementos correspondientes de args.

Excepciones

args es null.

o bien

Uno o varios elementos de args son null.

Se invocan los inicializadores de clase y al menos uno genera una excepción.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el GetTypeArray método para enumerar los tipos de los elementos de una matriz.

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

Se aplica a