c# 反射简单使用

类库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();
        }
    }
原文地址:https://www.cnblogs.com/mokeyish/p/5306278.html