InvokeMember

 1 None.gif using  System;
 2 None.gif using  System.Reflection;
 3 None.gif
 4 None.gif namespace  Test
 5 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 6InBlock.gif    public interface ICClassA
 7ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 8InBlock.gif        ICClassB GetB();
 9ExpandedSubBlockEnd.gif    }

10InBlock.gif    public interface ICClassB
11ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
12InBlock.gif        ICClassC GetC();
13ExpandedSubBlockEnd.gif    }

14InBlock.gif    public interface ICClassC
15ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
16InBlock.gif        ICClassA GetA();
17ExpandedSubBlockEnd.gif    }

18InBlock.gif    public class ClassA : ICClassA
19ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
20InBlock.gif        public ICClassB GetB()
21ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
22InBlock.gif            return new ClassB() as ICClassB;
23ExpandedSubBlockEnd.gif        }

24ExpandedSubBlockEnd.gif    }

25InBlock.gif    public class ClassB : ICClassB
26ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
27InBlock.gif        public ICClassC GetC()
28ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
29InBlock.gif            return new ClassC() as ICClassC;
30ExpandedSubBlockEnd.gif        }

31ExpandedSubBlockEnd.gif    }

32InBlock.gif    public class ClassC : ICClassC
33ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
34InBlock.gif        public ICClassA GetA()
35ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
36InBlock.gif            return new ClassA() as ICClassA;
37ExpandedSubBlockEnd.gif        }

38ExpandedSubBlockEnd.gif    }

39InBlock.gif    public class test
40ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
41InBlock.gif        public static string GetInfo()
42ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
43InBlock.gif            System.Type typeA = typeof(ClassA);
44InBlock.gif            System.Type typeB = typeof(ClassB);
45InBlock.gif            System.Type typeC = typeof(ClassC);
46InBlock.gif            object objA = Activator.CreateInstance(typeA);
47InBlock.gif            object objB = typeA.InvokeMember("GetB", BindingFlags.InvokeMethod, null, objA, null);
48InBlock.gif            object objC = typeB.InvokeMember("GetC", BindingFlags.InvokeMethod, null, objB, null);
49InBlock.gif            return objA.GetType().ToString() + "+" + objB.GetType().ToString() + "+" + objC.GetType().ToString();
50ExpandedSubBlockEnd.gif        }

51ExpandedSubBlockEnd.gif    }

52ExpandedBlockEnd.gif}

53 None.gif

转载于:https://www.cnblogs.com/gamebaby/archive/2007/07/05/807489.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值