请教微软的技术专家。一个完全不合理的问题!C#足够变态的问题!

colinfly colinfly 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
当我这么写的时候
1:Type t = typeof (IOPCGroups);
2:int i;


3:i=Groups.Count;
系统会在运行到3:时出现
Object reference not set to an instance of an object.
异常。

而当我在第三句前加上i=(int)t.InvokeMember ("Count", BindingFlags.Public | BindingFlags.GetField | BindingFlags.GetProperty, null, Groups, new object [] {});
这句沃并未实际用到的话时,就正常了!
能告诉我为什么呢!

1:Type t = typeof (IOPCGroups);
2:int i;

21:i=(int)t.InvokeMember ("Count", BindingFlags.Public | BindingFlags.GetField | BindingFlags.GetProperty, null, Groups, new object [] {});

3:i=Groups.Count;


...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
colinfly
C# 111,129 成员 642,539 内容