What is reflaction in C#.net?

Showing Answers 1 - 3 of 3 Answers

ravi_teja

  • Jan 9th, 2006
 

Reflection is a notable addition to the .NET Framework. Through Reflection, a program collects and manipulates its own metadata. It is a powerful mechanism to introspect the assemblies and objects at runtime. The Reflection APIs are contained in the System.Reflection namespace. Reflection allows the programmer to inspect and collect information about the type, properties, methods and events of an object and to invoke the methods of that object through the Invoke method. Reflection is a powerful tool to develop Reverse Engineering applications, class browsers and property editors.

Collecting metadata of an assembly and discovering the types of classes in it.
Dynamic invocation of methods and properties.

Through late binding, the properties and methods of a dynamically instantiated object can be invoked based on type discovery.
Creating types at runtime using Reflection.Emit.

This is the most usable feature of reflection. The user can create new types at runtime and use them to perform required tasks.

  Was this answer useful?  Yes

Ashish Sarangi

  • Feb 23rd, 2006
 

Whenever we compile a programme under framework architecture we get assembly in form of exe or dll(which contains the IL & Metadata). Within the Metadat all the information about the class is retained like :-

private & public key

assembly version

structure information

type info

we can get all these information through reflection at runtime. Reflection also demonstrate the example of late binding.

  Was this answer useful?  Yes

Ehanthalingam.G

  • Mar 7th, 2006
 

A compiler for the common language runtime (CLR) will generate metadata during compilation and store the metadata (in a binary format) directly into assemblies and modules to avoid irregularities.

Reflection is the ability to read metadata at runtime. Using reflection, it is possible to uncover the methods, constructors,properties, parameters and events of a type, and to invoke them dynamically. Reflection also allows us to create new types at runtime.

Reflection generally begins with a call to a method present on every object in the .NET framework: GetType. The GetType method is a member of the System.Object class, and the method returns an instance of System.Type. System.Type is the primary gateway to metadata. System.Type is actually derived from another important class for reflection: the MemeberInfo class from the System.Reflection namespace. MemberInfo is a base class for many other classes who describe the properties and methods of an object, including FieldInfo, MethodInfo, ConstructorInfo, ParameterInfo, and EventInfo among others. As you might suspect from thier names, you can use these classes to inspect different aspects of an object at runtime.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions