反射的小例子

项目名:ca 添加引用 code.google.com 和icen
class Program
    {
        static void Main(string[] args)
        {
            Assembly assembly = Assembly.Load("code.google.com");
            Ihello hello = (Ihello)assembly.CreateInstance("code.google.com.a");
            hello.printHello("tom");

            Console.ReadLine();
        }
    }

项目名 code.google.com 添加引用 icen
public class a:Ihello
    {
        public void printHello(string name)
        {
            Console.WriteLine("Hello : "+name);
        }
    }

 

项目名 icen
public interface Ihello
    {
        void printHello(string name);
    }

posted on 2011-12-26 09:45  雨渐渐  阅读(121)  评论(0编辑  收藏  举报

导航