请教微软的技术专家。一个完全不合理的问题!C#足够变态的问题!
当我这么写的时候
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;