C#反射

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Country cy = (Country)Assembly.Load("Test").CreateInstance("Test.America");
            Console.WriteLine(cy.name);
            Console.ReadKey();
        }
    }
    class Country
    {
        public string name;
    }
    class China : Country
    {
        public  China()
        {
            name = "你好";
        }
    }
    class America : Country
    {
        public  America()
        {
            name = "Hello";
        }
    }
}

 

posted @ 2015-11-15 11:02  马羊  阅读(66)  评论(0编辑  收藏