Mega Code Archive

 
Categories / VB.Net / Reflection
 

Type IsGenericTypeDefinition

Imports System Imports System.Reflection Imports System.Collections.Generic Imports Microsoft.VisualBasic Public Class Test     Private Shared Sub DisplayGenericTypeInfo(ByVal t As Type)         Console.WriteLine(t.ToString())         Console.WriteLine(t.IsGenericTypeDefinition)         Console.WriteLine(t.IsGenericType)         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() & " " & tParam.GenericParameterPosition )                 Else                     Console.WriteLine(tParam.ToString())                 End If             Next tParam         End If     End Sub     Public Shared Sub Main()         Dim d As New Dictionary(Of String, Test)()         DisplayGenericTypeInfo(d.GetType())         DisplayGenericTypeInfo(d.GetType().GetGenericTypeDefinition())         DisplayGenericTypeInfo(GetType(String))     End Sub  End Class