Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TypeBuilder::MakeGenericType Method (array<Type^>^)

 

Substitutes the elements of an array of types for the type parameters of the current generic type definition, and returns the resulting constructed type.

Namespace:   System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

public:
virtual Type^ MakeGenericType(
	... array<Type^>^ typeArguments
) override

Parameters

typeArguments
Type: array<System::Type^>^

An array of types to be substituted for the type parameters of the current generic type definition.

Return Value

Type: System::Type^

A Type representing the constructed type formed by substituting the elements of typeArguments for the type parameters of the current generic type.

Exception Condition
InvalidOperationException

The current type does not represent the definition of a generic type. That is, IsGenericTypeDefinition returns false.

ArgumentNullException

typeArguments is null.

-or-

Any element of typeArguments is null.

ArgumentException

The Module property of any element of typeArguments is null.

-or-

The Assembly property of the module of any element of typeArguments is null.

Use this method when your emitted code requires a type constructed from the current generic type definition. It is not necessary to call the CreateType method before calling the MakeGenericType method on a TypeBuilder that represents a generic type definition. If the current TypeBuilder does not represent the definition of a generic type, an InvalidOperationException is thrown.

The object returned by this method functions as a placeholder for a constructed generic type in your emitted code. It is an instance of a class derived from Type that has limited capabilities. In particular:

Type^ t1 = tbldr->MakeGenericType(String::typeid);
Type^ t2 = tbldr->MakeGenericType(String::typeid);
bool result = t1->Equals(t2);

.NET Framework
Available since 2.0
Silverlight
Available since 2.0
Return to top
Show:
© 2017 Microsoft