Reflection is the ability of a managed code to read its own
metadata for the purpose of finding assemblies, modules and type information at
runtime. it allows code to inspect other code within the same system. The main
class for reflection is the System. Type class, which is an abstract class
representing a type in the Common Type System (CTS). When you use this class,
you can find the types used in a module and namespace and also determine if a
given type is a reference or value type.
Benefits of Reflection C#
1.
Use Module to get all global and non-global methods defined in the module.
2.
Use Assembly to load modules listed in the assembly manifest.
3.
Use PropertyInfo to get the declaring type,
reflected type, data type, name and writable status of a
property or to get and set property values.
4.
Use MethodInfo to look at information such as parameters, name, return type, access modifiers, and implementation details.
5.
Use EventInfo to find out the event-handler data type, the name, declaring type and custom attributes.
6.
Use ConstructorInfo to get data on the parameters,
access modifiers, and implementation details of a constructor.
|