IList继承了ICollection,Count是ICollection的成员。
假如有代码:
string[] s = new string[10];
IList list = s as IList;
ICollection col = s as ICollection;
// 运行时,在vs.net开发环境的命令窗口中,察看list.Count时,会报错。
// 察看col.Count却正常。
int listCount = list.Count;
int colCount = col.Count;不论运行还是在命令窗口中察看,上面两个变量的值都是正确的,也没有任何异常发生,这是为什么?
希望提供有依据的答案。一周内结贴,如果我没有搞忘的话:D

解决方案 »

  1.   

    it doesn't work with ToString(), GetType() either, it is a known bug, it is fixed in VS 2005
      

  2.   

    好。我也想明白了,不是上面这个原因,否则col.Count也将看不到结果。
    大概是在调试器中只能访问当前接口明确定义的成员,继承来的接口都不能访问。
    结贴,免得搞忘了。
      

  3.   

    如果编码里可以,但调试器里看不到,只能说明是bug,再说,在Immediate Windows里的Intellisense里是能看到Count属性的