What is reflection?


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

No comments:

Post a Comment