what is reflection in C#, what are the benefit. How to use it to get benifit
.net, c#, reflection
Solution
Reflection allows you to write code that can inspect various aspects about the code itself.
It enables you to do simple things like:
Check the type of an object at runtime (simple calls to `typeof()` for example)
Inspect the Attributes of an object at runtime to change the behavior of a method (the various serialization methods in .NET)
To much more complicated tasks like:
- Loading an assembly at runtime, finding a specific class, determining if it matches a given Interface, and invoking certain members dynamically.
The earlier is much more common usage. The later is helpful to developers working on plug-in architectures for their applications or people who want to swap assemblies at runtime depending on configuration changes.
Problem
I was reading an article at msdn about reflection but i was not able to understand it even 10% about its benifit, its usage. Could you please provide some brief overview what is reflection and how can i take benefit from it.