15.3. Building a Custom Metadata Viewer

To illustrate the basic process of reflection (and the usefulness of System.Type), let's create a Console Application named MyTypeViewer. This program will display details of the methods, properties, fields, and supported interfaces (in addition to some other points of interest) for any type within mscorlib.dll (recall all .NET applications have automatic access to this core framework class library) or a type within MyTypeViewer itself. Once the application has been created, be sure to import the System.Reflection namespace.

// Need to import this namespace to do any reflection!
using System.Reflection;

15.3.1. Reflecting on Methods

The Program class will be updated to define a number of static methods, ...

Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition 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.