Exemplo n.º 1
0
        static void Main(string[] args)
        {
            LYW liuyanwei = new LYW();
            Type type = liuyanwei.GetType();
               // Program.getMember(type);

            //转换类型使用晚期绑定
            // LYW lateBindingLYW = (LYW)getSelfObject(type);lateBindingLYW.speak();
            //反射获取方法使用晚期绑定的类
            object lateBindingLYW = getSelfObject(type);

            MethodInfo method = type.GetMethod("speak");
            method.Invoke(lateBindingLYW, null);//对象,参数

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            LYW  liuyanwei = new LYW();
            Type type      = liuyanwei.GetType();
            // Program.getMember(type);

            //转换类型使用晚期绑定
            // LYW lateBindingLYW = (LYW)getSelfObject(type);lateBindingLYW.speak();
            //反射获取方法使用晚期绑定的类
            object lateBindingLYW = getSelfObject(type);

            MethodInfo method = type.GetMethod("speak");

            method.Invoke(lateBindingLYW, null);//对象,参数


            Console.ReadLine();
        }