How to: Obtain Type and Member Information from an Assembly 

The System.Reflection namespace contains many methods for obtaining information from an assembly. This section demonstrates one of these methods. For additional information, see Reflection Overview.

The following example obtains type and member information from an assembly.


using System;
using System.Reflection;
class Asminfo1
  public static void Main(string[] args)
   Console.WriteLine ("\nReflection.MemberInfo");

      //Get the Type and MemberInfo. 
      //Insert the fully qualified class name inside the quotation marks in the following statement.
      Type MyType =Type.GetType("System.IO.BinaryReader"); 
      MemberInfo[] Mymemberinfoarray = MyType.GetMembers(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.Instance|BindingFlags.DeclaredOnly); 

      //Get and display the DeclaringType method. 
      Console.Write("\nThere are {0} documentable members in ", Mymemberinfoarray.Length);
      Console.Write("{0}.", MyType.FullName); 

      foreach (MemberInfo Mymemberinfo in Mymemberinfoarray) 
           Console.Write("\n" + Mymemberinfo.Name);

See Also

Community Additions