What is reflection, DOT NET Programming

Reflection

All .NET assemblies have metadata information stored  the types defined in the modules. And This metadata information can be accessed by mechanism called as "Reflection". The System.Reflection is used to browse through the metadata information.

By Using the reflection we can also dynamically invoke methods using the System.The Type.InvokeMember. Below is the sample source code if needed we can also get this code from the CD provided, go to the  "Source code" folder in the "Reflection Sample" folder.

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

1506_reflection display.jpg


Sample source code uses reflection to browse through "Button" class of "Windows.Forms". If we compile & run the program following is the output as shown in "Sample Reflection Display". By Using the reflection we can also dynamically invoke a method using "System.Type.Invoke Member".

 

Posted Date: 9/18/2012 7:33:38 AM | Location : United States







Related Discussions:- What is reflection, Assignment Help, Ask Question on What is reflection, Get Answer, Expert's Help, What is reflection Discussions

Write discussion on What is reflection
Your posts are moderated
Related Questions
Perform Arithmetic operations on Floating Values - C# Program Hello, I've been trying so many codes for this but those codes didn't work well. Please write the code for Perfor

What are the steps involved to fill a dataset ? The sample code is shown below: Private Sub LoadData() Dim strConnectionString As String strConnectionString = AppSetti

Create page website to catalog some of the music: A homepage:  that automatically comes up when you go to 127.0.0.1:3000 (instead of the default Ruby-on-Rails pa

What is Difference between NameSpace and Assembly? Following are the differences among namespace and assembly: Assembly is physical grouping of logical units, Namespace, log

What are the main components of .NET Framework? .NET Framework gives enormous benefits to software developers in comparison to the advantages given by other platforms. Microsof

I have a responsive database structure and web template. I need someone to prepare the code (.net, jquery ) to make interaction with database . Insert, edit , save . Plus a custom

Question: (a) Give three key differences between the DetailsView and FormView controls. (b) The ASP.NET 2.0 Framework introduces the idea of validation groups. How Valida

Define XPATH. XPATH is an XML query language to select specific section of an XML document. By using XPATH you can address or filter elements and text in a XML document. For il

Web Developer Project Description: We need of an expert web developer for long term association, please apply with models if you have the subsequent skills: ASP.NET MVC 3

What is "Common Language Runtime" (CLR)?  CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that changes a MSIL code into the host machine language code,