3.4. Type class and Reflection namespace

The Type class is our entry point into the Reflection namespace and its members. Reflection, in .NET terms, is the ability to examine the capabilities of classes at runtime. By using Reflection, we can take a class and examine its methods, properties, constructors, fields, events, and other members – that is, the metadata associated with a class.

The Type class contains methods such as GetMethods and GetProperties that are used to return member information. By using the classes inside the Reflection namespace, we can go deeper and examine, for example, parameters of the methods (using System.Reflection.MethodInfo class) and even call methods via the Invoke method.

The following example can be used as ...

Get A Programmer's Guide to .NET 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.