Reflection for Methods, Properties, Events, and More

Thus far, we’ve mainly focused on reflection to discover types and perform some operations based on those. Because types are containers for other concepts, we can descend the ladder of reflection to discover more about those members, too. Expectedly, every System.Type object exposes methods that allow you to inspect the type’s methods, properties, events, constructors, and fields. For example, to retrieve all the methods on System.Int32 and make sense of the overloads by grouping them by name, we can write the following code:

image

MethodInfo objects have a bunch of interesting properties, revealing ...

Get C# 4.0 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.