Assign the Integer type to the type parameter of the Example method : Type « Reflection « VB.Net

4.Data Structure
5.Data Types
7.Date Time
10.File Directory
13.Internationalization I18N
14.Language Basics
16.Network Remote
20.Windows Presentation Foundation
21.Windows System
VB.Net » Reflection » TypeScreenshots 
Assign the Integer type to the type parameter of the Example method

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)
    End Sub 'Main

    Private Shared Sub DisplayGenericMethodInfo(ByVal mi As MethodInfo)

        If mi.IsGenericMethod Then
            Dim typeArguments As Type() = mi.GetGenericArguments()
            For Each tParam As Type In typeArguments
                If tParam.IsGenericParameter Then
                    Console.WriteLine(vbTab & vbTab & tParam.ToString())
                End If
            Next tParam
        End If
    End Sub
End Class

Related examples in the same category
1.Get method from Type
2.Type.GetElementType returns the Type of the object referred to
3.Type.IsArray Property gets a value indicating whether the Type is an array.
5.Type.IsInstanceOfType determines whether the specified object is an instance of the current Type.
6.Type.IsInterface tells whether the Type is an interface; that is, not a class or a value type.
9.Type.IsNestedFamily Property tells whether the Type is nested and visible only within its own family.
10.Type.IsNestedPrivate Property
11.Type.IsNestedPublic Property tells whether a class is nested and declared public.
12.Type.IsPublic Property tells whether the Type is declared public.
13.Type.IsSealed Property tells whether the Type is declared sealed.
14.Type.IsSerializable Property tells indicating whether the Type is serializable.
16.Type.IsValueType Property tells whether the Type is a value type.
17.Type.IsVisible Property tells whether the Type can be accessed by code outside the assembly.
18.Type Class Represents type declarations
19.Type.Assembly Property
20.Type.AssemblyQualifiedName Property
21.Type.Attributes Property gets the attributes associated with the Type.
22.Type.BaseType Property gets the type from which the current Type directly inherits.
24.Type.DeclaringMethod gets a MethodBase
25.Invoke generic method
26.Type.DeclaringType gets the type that declares the current nested type or generic type parameter.
27.Type.DefaultBinder gets a reference to the default binder
29.Type.Equals Method (Type)
30.Type.FilterAttribute represents the member filter used on attributes. This field is read-only.
31.Type.FilterNameIgnoreCase Field
32.Type.FindInterfaces returns interfaces implemented or inherited by the current Type.
34.Type.FullName gets the fully qualified name of the Type
35.Type.GenericParameterPosition gets the position of the type parameter
36.Type.GetArrayRank gets the number of dimensions in an Array.
37.Type.GetConstructor (BindingFlags, Binder, Type[], ParameterModifier[])
38.Type.GetConstructor (Type[])
39.Type.GetConstructors (BindingFlags)
40.Get Constructors with Binding flags
41.Type.GetElementType returns the Type of the object encompassed or referred
42.Type.GetEvent returns the EventInfo object representing the specified public event.
43.Type.GetEvents (BindingFlags)
44.Type.GetEvents returns all the public events that are declared or inherited by the current Type.
45.Type.GetField searches for the public field with the specified name.
46.Type.GetFields (BindingFlags)
47.Type.GetFields returns all the public fields of the current Type.
51.Type.GetMember searches for the public members with the specified name.
52.Type.GetMember searches for the specified members, using the specified binding constraints.
53.Type.GetMember (String, MemberTypes, BindingFlags)
54.Type.GetMembers (BindingFlags)
55.Type.GetMembers returns all the public members of the current Type.
56.Type.GetMethod Method
57.Type.GetMethod searches for the specified method, using the specified binding constraints.
58.Type.GetMethod with modifiers, binding constraints and calling convention.
59.Get MethodA(ByVal i() As Integer)
60.Get MethodA(ByRef r As Integer)
61.Get MethodA(ByVal i As Integer, ByRef o As Integer)
62.Type.GetMethod get methods by public method whose parameters match the specified argument types.
63.Get MethodA(i As Integer())
64.Get MethodA(ByRef r As Integer)
65.Get MethodA(i As Integer, ByRef r As Integer)
66.Type.GetMethods (BindingFlags)
67.Type.GetNestedTypes (BindingFlags)
68.Type.GetNestedTypes returns the public types nested in the current Type.
69.Type.GetProperties (BindingFlags)
70.Get the nonpublic properties
71.Type.GetProperties returns all the public properties of the current Type.
72.Type.GetProperty (String) searches for the public property with the specified name.
73.Type.GetProperty (String, BindingFlags) searches property, using the specified binding constraints.
74.Type.GetProperty searches for the public property with the specified name and return type.
75.Type.GetProperty get properties by parameters types and modifiers.
76.Type.GetProperty searches for public property whose parameters match the specified argument types.
77.Type.GetType Method gets the Type with the specified name, performing a case-sensitive search.
78.Type.GetTypeFromCLSID (Guid) gets the type associated with the specified class identifier (CLSID).
79.Type.GetTypeFromCLSID (Guid, Boolean)
80.Type.GetTypeFromCLSID (Guid, String)
81.Type.GetTypeFromCLSID Method (Guid, String, Boolean)
82.Type.GetTypeFromHandle gets the type referenced by the specified type handle.
83.Type.GetTypeFromProgID (String, Boolean)
84.Type.GetTypeFromProgID gets type with program identifier (progID) from the specified server
85.Type.GetTypeHandle gets the handle for the Type of a specified object.
86.Type.GUID Property gets the GUID associated with the Type.
87.Type.HasElementType tells whether the current Type encompasses or refers to another type
88.Creates the type 'array of Example
89.Gets the Test method, defined above, and examines its parameters
90.Create pointer and ByRef types to use when you define method parameters
91.Type.HasElementTypeImpl: Determine whether a variable refers to an array or pointer or reference type
92.Determine whether myType is an array, pointer, reference type
93.Invokes specified member, using binding constraints and matching the specified argument list.
94.Type.IsAbstract tells whether the Type is abstract and must be overridden.
95.Type.IsAnsiClass tells whether the string format attribute AnsiClass is selected for the Type.
96.Type.IsArray tells whether the Type is an array.
97.Type.IsArrayImpl tells whether the Type is an array.
99.Is generics assignable
100.Type.IsAutoLayout tells whether the class layout attribute AutoLayout is selected for the Type.
101.Type.IsClass tells whether the Type is a class; that is, not a value type or interface.
102.Type.IsContextful Property tells whether the Type can be hosted in a context.
103.Determine whether the types are marshalled by reference
104.Determine whether the types are primitive datatypes
105.Type.IsEnum Property tells whether the current Type represents an enumeration.
106.Type.MakeArrayType returns an array of the current type with the specified number of dimensions.
107.Create a Type object that represents a two-dimensional array of Example objects
108.Demonstrate an exception when an invalid array rank is specified
109.Create a Type object that represents a ByRef parameter of type Example
110.Type.Missing Field represents a missing value in the Type information.
111.Type.Module Property gets the module (DLL) in which the current Type is defined.
112.Type.ReflectedType Property gets the class object that was used to obtain this member.
113.Viewing Type Information
114.Lists all the public constructors of the System.String class.
116.Display information about the GetValue method of FieldInfo.
117.Lists all the members of the System.IO.BufferedStream class.  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.