惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
量子位
博客园 - 司徒正美
IT之家
IT之家
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
Vercel News
Vercel News
B
Blog
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
小众软件
小众软件
罗磊的独立博客
博客园 - 叶小钗
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学

博客园 - gamebaby

去掉rhel 6的缺少授权证书提示 c++消息 脚踏实地向前走 读xml内容 - gamebaby - 博客园 InvokeMember 项目经理应该知道的. Clear Sqlserver log 获取表信息 Email(VB.net) - gamebaby - 博客园 Email(C#) - gamebaby - 博客园 主外键 转义符 常规触发器 创建数据库 触发器 CASE 语句 事务处理 游标例子2(转载) 游标例子1(转载)
Invoke
gamebaby · 2007-07-05 · via 博客园 - gamebaby

 1using System;
 2using System.Reflection;
 3
 4namespace Test
 5{
 6
 7
 8    public class A
 9    {
10        public virtual string method(int i) return i.ToString(); }
11    }

12
13    public class B
14    {
15        public virtual string method(int i, int o) return i.ToString()+o.ToString(); }
16    }

17
18    class Mymethodinfo
19    {
20        public static void Main()
21        {
22            A MyA = new A();
23            B MyB = new B();
24
25            // Get the Type and MethodInfo.
26            Type MyTypea = typeof(A);//Type.GetType("A");
27            MethodInfo Mymethodinfoa = MyTypea.GetMethod("method");
28
29            Type MyTypeb = typeof(B);//Type.GetType("B");
30
31            MethodInfo Mymethodinfob = MyTypeb.GetMethod("method");
32
33            // Get and display the Invoke method.
34            Console.Write("\nFirst method - " + MyTypea.FullName +
35                " returns " + Mymethodinfoa.Invoke(MyA, new object[] 100}));
36            Console.Write("\nSecond method - " + MyTypeb.FullName +
37                " returns " + Mymethodinfob.Invoke(MyB, new object[] 100200 }));
38            Console.Read();
39        }

40    }

41
42}

 posted on 2007-07-05 17:59  gamebaby  阅读(319)  评论(0)    收藏  举报

刷新页面返回顶部