Chapter 22. Reflection

This chapter introduces the classes in C#'s System.Reflection namespace. We assume that you are familiar with the general concept of reflection and are somewhat familiar with Java's reflection.

Reflection can be thought of as a “back door” way to get information about objects. In OOP, we can call a method on an object simply by knowing that the method exists on the object. Often, though, when we are dealing with objects in a generic fashion, we do not know about their methods in advance, and sometimes we don't even know the object's type. To call a method on any object without having prior knowledge of the object or its methods, we must query all the methods of the object, find the desired method, and invoke it by passing ...

Get .NET for Java Developers: Migrating to C# 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.