Reflecting Types

Reflection enables retrieving information on programs, including modules, types, and type members defined within an assembly. For example, you might want to enumerate all types and type members defined in the People.dll assembly. Take a look at the following code:

Dim asm = Assembly.LoadFrom("People.dll")Console.WriteLine("Enumerating types:")For Each t In asm.GetTypes    Console.WriteLine("Type name: {0}", t.ToString)    Console.WriteLine(" Constructors:")    For Each constructor In t.GetConstructors        Console.WriteLine("     " + constructor.ToString)    Next    Console.WriteLine(" Methods:")    For Each method In t.GetMethods        Console.WriteLine("     " + method.ToString)    Next    Console.WriteLine(" ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.