類庫dll,將生成ExampleLib.dll文件
namespace ExampleLib
{
public class Example
{
public static string FuncA()
{
return "FuncA";
}
public string FuncB()
{
return "FuncB";
}
}
}
反射調用。創建實例並調用示例中的方法
class Program
{
static void Main(string[] args)
{
dynamic example = Assembly.Load("ExampleLib").CreateInstance("ExampleLib.Example");
Console.WriteLine(example.FuncB());
Console.ReadKey();
}
}