Reflection in C#


The Reflection is mainly derived from the Base library – “System.Reflection”, This reflection can be mainly used to specify the details such as meta data, In Other words, Reflection is used to provide the meta details of a property or a class or method.
Suppose we have a class to be referred and need to access the object or a method from that class, in this case, we can go for reflection to access the property by providing the valid data about the property and can retrieve the value of the property in our calling class.
It will throw error incase we have provided invalid property name or class name or simply the name of element at compile time, but it will throw exception in case of failure at the run time of the application.
Example,

AssemblyName                è          Retrieve the unique name of an assembly
EventInfo                           è          Available Event Metadata can be accessed through the event info
 ConstructorInfo                è          Define constructor for a class and provide meta data of class
       Information
ParameterInfo                   è         Parameters of a method and metadata can be accessed
      for the required Method
MethodInfo                        è        Hold the method available in a class and metadata can be accessed
      for the required Method
MemberInfo                      è         Member Attribute Information can be accessed using the member 
      metadata
PropertyInfo                      è         As Like Method and Class, Property also be retrieved, about  
                                                        Property Attribute using property metadata












Comments

Popular posts from this blog