O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

var res = from method in typeof(int).GetMethods()          group method by method.Name into g          select new { Name = g.Key, Overloads ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required