Reflection in C#
This article explains how to make use ofSystem.Reflection class to extract each and every detail of any classin .Net Framework.The MemberInfo class available in System.Reflection namespace is anabstract class.It discovers the attributes of a member and provides access to themember metadata.We need to assign the details we need to query about a type viz.Constructors/Methods/Interfaces/Fields/Property etc. to the MemberInfoclass local variable.For this, We can make use of the methodsGetFields/GetMethods/GetInterfaces etc. In this code example, the userwill be prompted to select the class about which he would like to viewdetails.The details of the class selected (available Methods/Interfaces/Fields)will be listed out in the corresponding listboxes.
To compile, type: csc reflection.csDownload reflection.cs
Here's what it looks like













No comments yet... Be the first to leave a reply!