Imports System
Imports System.Reflection
Imports System.Collections.Generic
Imports Microsoft.VisualBasic
Public Class Base(Of T, U)
End Class
Public Class Derived(Of V)
Inherits Base(Of Integer, V)
End Class
Public Class Test
Public Shared Sub Main()
Dim derivedType As Type = GetType(Derived(Of ))
DisplayGenericTypeInfo(derivedType)
DisplayGenericTypeInfo(derivedType.BaseType)
End Sub 'Main
Private Shared Sub DisplayGenericTypeInfo(ByVal t As Type)
Console.WriteLine(t.IsGenericTypeDefinition)
Console.WriteLine(t.IsGenericType)
Console.WriteLine(t.ContainsGenericParameters)
If t.IsGenericType Then
Dim typeArguments As Type() = t.GetGenericArguments()
Console.WriteLine(typeArguments.Length)
For Each tParam As Type In typeArguments
If tParam.IsGenericParameter Then
Console.WriteLine(tParam.ToString() & " (unassigned - parameter position " & tParam.GenericParameterPosition & ")")
Else
Console.WriteLine(vbTab & vbTab & tParam.ToString())
End If
Next tParam
End If
End Sub
End Class