articles

Home / DeveloperSection / Articles / Reflection in C#.Net

Reflection in C#.Net

AVADHESH PATEL5895 09-Jul-2012

Reflection provides objects (of type Type Class) that encapsulate assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. If you are using attributes in your code, Reflection enables you to access them.CLR is an internal reflection that checks the framework version.

Through reflection

1.       I can load assembly dynamically.

2.       I can open, browse the assembly.

3.       Reflection gets the info like version of assembly. Using manifest we can go for browsing assembly.

4.       Access all info of class to base class.

5.       Without using header file we can call dll function by reflection (let binding).

6.       Through reflection we can add info in a class.

7.       Through reflection we can achieve late binding. 

Example:

How to brows DLL with the help of Reflection?

Step 1: Type below code on notepad and save with info.cs in drive D

Reflection in C#.Net

Step 2: Open Visual studio prompt and make DLL of info.cs file

Reflection in C#.Net

Step 3: Type below code on notepad and save with showinfo.cs in drive D

 

Reflection in C#.Net 

Step 4: Open Visual studio prompt and compile the showinfo.cs  file

Reflection in C#.Net

Step 5: Execute showinfo.cs file 

Reflection in C#.Net

  Step 6: we can browse info.dll file via ildasm and check class, function name 

Reflection in C#.Net 

Reflection in C#.Net



Updated 07-Sep-2019
Avadhesh Kumar Patel District Project Manager - Aligarh 14 months work experience in Panchayati Raj Department Sector as District Project Manager & 12 months work experience in IT Sector as Software Engineer. :-)

Leave Comment

Comments

Liked By