Type.GetTypeArray Method
Gets the types of the objects in the specified array.
[Visual Basic] Public Shared Function GetTypeArray( _ ByVal args() As Object _ ) As Type() [C#] public static Type[] GetTypeArray( object[] args ); [C++] public: static Type* GetTypeArray( Object* args __gc[] ) []; [JScript] public static function GetTypeArray( args : Object[] ) : Type[];
Parameters
- args
- An array of objects whose types to determine.
Return Value
An array of Type objects representing the types of the corresponding elements in args.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentNullException | args is a null reference (Nothing in Visual Basic). |
| TargetInvocationException | The class initializers are invoked and at least one throws an exception. |
Remarks
If a requested type is non-public and the caller does not have ReflectionPermission to non-public objects outside the current assembly, this method returns a null reference (Nothing in Visual Basic) for the corresponding element in the result array.
Example
[Visual Basic] 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 [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); } [C++] Object* myObject[] = new Object*[3]; myObject->Item[0] = __box(66); myObject->Item[1] = S"puri"; myObject->Item[2] = __box(33.33); // Get the array of 'Type' class objects. Type* myTypeArray[] = Type::GetTypeArray(myObject); Console::WriteLine(S"Full names of the 'Type' objects in the array are:"); for (int h = 0; h < myTypeArray->Length ; h++) { Console::WriteLine(myTypeArray[h]->FullName); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard
See Also
Type Class | Type Members | System Namespace | ReflectionPermission