Assembly.GetTypes() : Assembly « System.Reflection « C# / C Sharp by API






Assembly.GetTypes()

  


using System; 
 
class MyClass { 
  int x; 
  int y; 
 
  public MyClass(int i) { 
    Console.WriteLine("Constructing MyClass(int). "); 
    x = y = i;  
    show(); 
  } 
 
  public MyClass(int i, int j) { 
    Console.WriteLine("Constructing MyClass(int, int). "); 
    x = i; 
    y = j; 
    show(); 
  } 
 
  public int sum() { 
    return x+y; 
  } 
 
  public bool isBetween(int i) { 
    if((x < i) && (i < y)) return true; 
    else return false; 
  } 
 
  public void set(int a, int b) { 
    Console.Write("Inside set(int, int). "); 
    x = a; 
    y = b; 
    show(); 
  } 
 
  // Overload set. 
  public void set(double a, double b) { 
    Console.Write("Inside set(double, double). "); 
    x = (int) a; 
    y = (int) b; 
    show(); 
  } 
 
  public void show() { 
    Console.WriteLine("Values are x: {0}, y: {1}", x, y); 
  } 
} 
 
class AnotherClass { 
  string remark; 
 
  public AnotherClass(string str) { 
    remark = str; 
  } 
 
  public void show() { 
    Console.WriteLine(remark); 
  } 
} 
 
/////////////////////////////////////

using System; 
using System.Reflection; 
 
class MainClass { 
  public static void Main() { 
    int val; 
 
    Assembly asm = Assembly.LoadFrom("MyClasses.exe"); 
 
    Type[] alltypes = asm.GetTypes(); 
    foreach(Type temp in alltypes) 
      Console.WriteLine("Found: " + temp.Name); 
 
    Console.WriteLine(); 
 
  } 
}

   
    
  








Related examples in the same category

1.Assembly.CodeBase
2.Assembly.EntryPoint
3.Assembly.EscapedCodeBase
4.Assembly.Evidence
5.Assembly.FullName
6.Assembly.GetCallingAssembly()
7.Assembly.GetCustomAttributes
8.Assembly.GetEntryAssembly()
9.Assembly.GetExecutingAssembly()
10.Assembly.GetExportedTypes
11.Assembly.GetName
12.Assembly.GetReferencedAssemblies
13.Assembly.GlobalAssemblyCache
14.Assembly.Load(AssemblyName name2)
15.Assembly.Load(String name)
16.Assembly.LoadFrom(String assemblyName)
17.Assembly.Location