Inspecting Types

Central to reflection is the abstract System.Reflection.MemberInfo class. Concrete classes are derived from MemberInfo to form representations of each member type, including constructors, methods, properties, and fields. For general information about each of the .NET member types, see Chapter 5.

Instances of classes derived from MemberInfo are obtained through the methods of the System.Type class; these methods are grouped by the member type they reflect and follow a clear pattern, each offering three forms, as shown in the following list:

  • GetXXX(System.Type[])

  • GetXXXs(System.Reflection.BindingFlags)

  • GetXXXs()

The XXX indicates a member type—for example, GetConstructor(Type[]), GetConstructors(BindingFlags), and GetConstructors()

Get C# for Java Developers 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.