what is reflection in C#, what are the benefit. How to use it to get benifit [closed]

Reflection allows you to write code that can inspect various aspects about the code itself.

It enables you to do simple things like:

  1. Check the type of an object at runtime (simple calls to typeof() for example)

  2. 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:

  1. 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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)