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
What are abstract classes? What are the distinct characteristics of an abstract class? An abstract class is a class that cannot be instantiated and is always used as a base cla

.NET is Compile Time OR RunTime Environment?   .Net's framework has CLS,CTS and CLR.CTS checks declaration of types at the time when u write code and CLS defines some rules and

Compute Average of 3 numbers - C# Program I didn't know the exact code for computing average of integer number. Can anybody suggest me the correct way for find out the average

Show the code for the file dependency in cache? Partial Class Default_aspx Public Sub displayAnnouncement() Dim announcement As String If Cache("announcement") Is Noth

How do we assign page specific attributes? The Page attributes are specified by using the @Page directive.

Web Developer Project Description: We are in need of an expert web developer for long term connection; please apply with samples if you have the subsequent skills: ASP.NET


Mention different types of data providers available in .NET Framework. .NET Framework Data Provider for SQL Server - Give access to Microsoft SQL Server 7.0 or later version. I

What is Post Cache substitution? The Post cache substitution is used when we want to cache the complete page but also require some of the dynamic region inside that cached page

What is serialization, how it works in .NET? Serialization is when you persist the state of an object to a storage medium so an exact copy can be re-created at a later stage. S