System.Type.GetGenericTypeDefinition Method

Returns a Type object that represents a generic type definition from which the current generic type can be constructed.


public virtual Type GetGenericTypeDefinition ()


A Type object representing a generic type from which the current type can be constructed.


InvalidOperationExceptionThe current type is not a generic type. That is, Type.HasGenericArguments returns false.


A generic type definition is a template from which other types can be constructed. For example, from the generic type definition G<T> (expressed in C# syntax; G(Of T) in Visual Basic or generic <typename T> ref class G in C++) you can construct and instantiate the type G<int> (G(Of Integer) in Visual Basic). Given a Type object representing this constructed type, the Type.GetGenericTypeDefinition method returns the generic type definition.

If two constructed types are created from the same generic type definition, using the same type arguments, the Type.GetGenericTypeDefinition method returns the same Type object for both types.

If you call the Type.GetGenericTypeDefinition method on a Type object that already represents a generic type definition, it returns the current Type.


An array of generic types is not itself generic. In the C# code A<int>[] v; or the Visual Basic code Dim v() As A(Of Integer), the type of variable v is not generic. Use Type.IsGenericType to determine whether a type is generic before calling Type.GetGenericTypeDefinition.

For a list of the invariant conditions for terms used in generic reflection, see the Type.IsGenericType property remarks.


For an example of using this method, see the example for Type.MakeGenericType.


Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0