Mega Code Archive

 
Categories / VB.Net / Reflection
 

Type GetMethods (BindingFlags)

Imports System Imports System.Reflection Imports System.Reflection.Emit Imports Microsoft.VisualBasic Public Class MyTypeClass     Public Sub MyMethods()     End Sub      Public Function MyMethods1() As Integer         Return 3     End Function      Protected Function MyMethods2() As [String]         Return "hello"     End Function  End Class  Public Class TypeMain     Public Shared Sub Main()         Dim myType As Type = GetType(MyTypeClass)         Dim myArrayMethodInfo As MethodInfo() = myType.GetMethods((BindingFlags.Public Or BindingFlags.Instance Or BindingFlags.DeclaredOnly))         Console.WriteLine(("The number of public methods is " & myArrayMethodInfo.Length.ToString() & "."))         DisplayMethodInfo(myArrayMethodInfo)     End Sub 'Main     Public Shared Sub DisplayMethodInfo(ByVal myArrayMethodInfo() As MethodInfo)         Dim i As Integer         For i = 0 To myArrayMethodInfo.Length - 1             Dim myMethodInfo As MethodInfo = CType(myArrayMethodInfo(i), MethodInfo)             Console.WriteLine((ControlChars.Cr + "The name of the method is " & myMethodInfo.Name & "."))         Next i     End Sub  End Class