TypeBuilder.MakeGenericType Method

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 override Type MakeGenericType(
	params Type[] typeArguments


Type: 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.


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


typeArguments is null.


Any element of typeArguments is null.


Any element of typeArguments does not satisfy the constraints specified for the corresponding type parameter of the current generic type.

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(typeof(string));
Type t2 = tbldr.MakeGenericType(typeof(string));
bool result = t1.Equals(t2);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft