|
Listing 7-4 extracted from chapter Reflection, late binding, attributes
Listing 7-3< > Listing 7-5
This listing can be compiled with the command line: csc.exe /target:exe Example_7_4.cs /r:Foo.dll Errors: 0 Warnings: 0
Example_7_4.cs
using System;
using System.Reflection;
class Program {
static void Main() {
Assembly assembly = Assembly.Load("Foo.dll");
Type type = assembly.GetType("NMFoo.Calc");
object obj = Activator.CreateInstance(type);
// 'obj' is a reference toward an instance of NMFoo.Calc.
}
}
Copyright Patrick Smacchia 2006 2007
|