Imports System
Imports System.IO
Imports System.Reflection
Class ListMembers
Public Shared Sub Main()
Dim t As Type = GetType(System.IO.BufferedStream)
Console.WriteLine("Listing all the members (public and non public) of the {0} type", t)
Dim fi As FieldInfo() = t.GetFields((BindingFlags.Static Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Static Fields")
PrintMembers(fi)
Dim pi As PropertyInfo() = t.GetProperties((BindingFlags.Static Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Static Properties")
PrintMembers(pi)
Dim ei As EventInfo() = t.GetEvents((BindingFlags.Static Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Static Events")
PrintMembers(ei)
Dim mi As MethodInfo() = t.GetMethods((BindingFlags.Static Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Static Methods")
PrintMembers(mi)
Dim ci As ConstructorInfo() = t.GetConstructors((BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Constructors")
PrintMembers(ci)
fi = t.GetFields((BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Instance Fields")
PrintMembers(fi)
pi = t.GetProperties((BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Instance Properties")
PrintMembers(pi)
ei = t.GetEvents((BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Instance Events")
PrintMembers(ei)
mi = t.GetMethods((BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public))
Console.WriteLine("Instance Methods")
PrintMembers(mi)
End Sub
Public Shared Sub PrintMembers(ms() As MemberInfo)
Dim m As MemberInfo
For Each m In ms
Console.WriteLine("{0}{1}", " ", m)
Next m
Console.WriteLine()
End Sub
End Class