Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What is reflection
What is reflection?
✍: Guest
All .NET assemblies have metadata information stored about the types defined in modules. This
metadata information can be accessed by mechanism called as “Reflection”.System. Reflection
can be used to browse through the metadata information.
Using reflection you can also dynamically invoke methods using System.Type.Invokemember.
Below is sample source code if needed you can also get this code from CD provided, go to
“Source code” folder in “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
Note :- Sample source code are compiled using VB.NET 2005.
Sample source code uses reflection to browse through “Button” class of “Windows.Forms”. If
you compile and run the program following is output as shown in “Sample Reflection Display”.
Using reflection you can also dynamically invoke a method using “System.Type.InvokeMember”.
Note :- System.Type.InvokeMember is left as homework for readers. Believe me you will
enjoy doing it yourself and the concept of reflection will be clearer.
2007-10-22, 4906👍, 0💬
Popular Posts:
How To Set session.gc_divisor Properly? - PHP Script Tips - Understanding and Using Sessions As you ...
What Does a HTML Document Look Like? A HTML document is a normal text file with predefined tags mixe...
How To Dump the Contents of a Directory into an Array? - PHP Script Tips - Working with Directoris a...
How do we enable SQL Cache Dependency in ASP.NET 2.0? Below are the broader steps to enable a SQL Ca...
What is the method to customize columns in DataGrid? Use the template column.