gamebaby
随笔- 22 文章- 1 评论- 13
博客园
首页
新随笔
新文章
联系
管理
订阅
InvokeMember
1
using
System;
2
using
System.Reflection;
3
4
namespace
Test
5
{
6
public
interface
ICClassA
7
{
8
ICClassB GetB();
9
}
10
public
interface
ICClassB
11
{
12
ICClassC GetC();
13
}
14
public
interface
ICClassC
15
{
16
ICClassA GetA();
17
}
18
public
class
ClassA : ICClassA
19
{
20
public
ICClassB GetB()
21
{
22
return
new
ClassB()
as
ICClassB;
23
}
24
}
25
public
class
ClassB : ICClassB
26
{
27
public
ICClassC GetC()
28
{
29
return
new
ClassC()
as
ICClassC;
30
}
31
}
32
public
class
ClassC : ICClassC
33
{
34
public
ICClassA GetA()
35
{
36
return
new
ClassA()
as
ICClassA;
37
}
38
}
39
public
class
test
40
{
41
public
static
string
GetInfo()
42
{
43
System.Type typeA
=
typeof
(ClassA);
44
System.Type typeB
=
typeof
(ClassB);
45
System.Type typeC
=
typeof
(ClassC);
46
object
objA
=
Activator.CreateInstance(typeA);
47
object
objB
=
typeA.InvokeMember(
"
GetB
"
, BindingFlags.InvokeMethod,
null
, objA,
null
);
48
object
objC
=
typeB.InvokeMember(
"
GetC
"
, BindingFlags.InvokeMethod,
null
, objB,
null
);
49
return
objA.GetType().ToString()
+
"
+
"
+
objB.GetType().ToString()
+
"
+
"
+
objC.GetType().ToString();
50
}
51
}
52
}
53
绿色通道:
好文要顶
关注我
收藏该文
与我联系
posted on 2007-07-05 18:04
gamebaby
阅读(409)
评论(0)
编辑
收藏
注册用户登录后才能发表评论,请
登录
或
注册
,
返回博客园首页
。
首页
博问
闪存
新闻
园子
招聘
知识库
最新IT新闻
:
·
iPhone 5四大猜想:泪珠状 带LED苹果标识
·
当当网Q4整体亏损1.3亿元 上年同期净利润1480万元
·
把孩子培养成为合格Geek的七个方法
·
担心网购的衣服不合身? 创业公司Clothes Horse用“问答”就能解决你的难题
·
评价社交媒体活动ROI的三个精确指标
»
更多新闻...
最新知识库文章
:
·
编程的艺术:漂亮的代码和漂亮的软件
·
GIT分支管理是一门艺术
·
编程:是一门艺术
·
编程是一门艺术吗?
·
对Java初学者的忠告
»
更多知识库文章...
China-pub 2011秋季教材巡展
China-Pub 计算机绝版图书按需印刷服务
公告
昵称:
gamebaby
园龄:
6年
粉丝:
0
关注:
0
<
2007年7月
>
日
一
二
三
四
五
六
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
随笔分类
.net(5)
c++(1)
java
Oracle
Sqlserver(12)
随笔档案
2011年12月 (1)
2008年7月 (1)
2008年3月 (1)
2007年7月 (3)
2007年5月 (1)
2007年4月 (1)
2007年3月 (1)
2006年11月 (11)
2006年3月 (1)
2006年2月 (1)
最新评论
阅读排行榜
评论排行榜
推荐排行榜