Imports System
Imports System.Reflection
Public Class Example
Public Shared Sub Generic(Of T)(ByVal toDisplay As T)
Console.WriteLine(vbCrLf & "Here it is: {0}", toDisplay)
End Sub
End Class
Public Class Test
Public Shared Sub Main()
Dim ex As Type = GetType(Example)
Dim mi As MethodInfo = ex.GetMethod("Generic")
Dim arguments() As Type = { GetType(Integer) }
Dim miConstructed As MethodInfo = mi.MakeGenericMethod(arguments)
Dim args() As Object = { 42 }
miConstructed.Invoke(Nothing, args)
Example.Generic(Of Integer)(42)
Dim miDef As MethodInfo = miConstructed.GetGenericMethodDefinition()
Console.WriteLine("The definition is the same: {0}", miDef Is mi)
End Sub
End Class