.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

What is reflection?

Posted By :Jegan R     Posted Date :November 01, 2010    Points :10   Category :.NET Framework 
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember ) , or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder)

You can also find related Interview Question to What is reflection?  below: 

What is reflection?

  
All .Net assemblies have metadata information stored about type defined in modules. These information can be accessed by a mechanism called as reflection. Using system.reflection we can browse the metadata information. We can also dynamically invoke methods using system.type.invokemember (More...)

What is Reflection?

  
Reflection is the ability to find out information about objects, the application details (assemblies), its metadata at run-time.
This allows application to collect information about itself and also manipulate on itself. It can be used effectively to find all the types in an assembly and/or dynamically invoke methods in an assembly. This includes information about the type, properties, methods and events of an object and to invoke the methods of object Invoke method can be used too. With reflection we can 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 Attributes (C#) are used in application, then with help of reflection we can access these attributes. It can be even used to emit Intermediate Language code dynamically so that the generated code can be executed directly.
(More...)

What is reflection?

  
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember ) , or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).
(More...)

How to use Reflection?

  
System.Reflection is used to browse through the metadata information. (More...)

How to code for reflection?

  
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim RType As Type
Dim RObject As Object
Dim MyButtons As New Windows.Forms.Button()
RType = MyButtons.GetType()
For Each RObject In RType.GetMembers
LstDisplay.Items.Add(RObject.ToString())
Next
End Sub
End Class (More...)

To how much extend a reflection code will be slow compare with compiled code?

  
8-10 times extend a reflection code will be slow compare with compiled code (More...)

what is the use of Reflection?

  
reflection is used to Get assembly metadata using code (More...)

What is Reflection?

  
Reflection is used to dynamically load a class , create object and invoke methods at run time. It can also be used read its own meta data to find assemblies, modules and type information at run time. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend