Reflection on Types
Reflection is one of those areas of object-oriented languages that remain a mystery to many programmers, for a number of reasons:
- The use of reflection is often frowned upon and viewed as being unnecessarily complex. But I can say from experience that reflection is both simple and powerful.
- Another reason why reflection tends to get a bad name is that its purpose is often misunderstood. The truth is this: Reflection has an important place in this era of loosely coupled software elements.
The true power of reflection lies in its ability to look at the types in a given piece of C# code. Using reflection, you can easily discover the most intimate details about a given C# type—without the need to have compile-time knowledge. In other words, you can discover the necessary details at runtime! This information has important benefits in a variety of programming scenarios.
Now let's make a start at looking into C# reflection techniques.