代码之家  ›  专栏  ›  技术社区  ›  Mashmagar

在VS2008IDE中,类名周围出现方括号意味着什么?

  •  1
  • Mashmagar  · 技术社区  · 16 年前

    在VS2008的监视窗口中,我看到一个 IEnumerable<classX> . 扩展 IEnumerable ,某些元素的值为 {classX} {[classX]} . 有什么区别?为什么有些上面有方括号?

    1 回复  |  直到 16 年前
        1
  •  0
  •   Palak.Maheria    12 年前

    花括号内的类表示所引用对象的动态类型。e、 下面的代码应该解释这个。。。

    class Parent1
    {
     int p1;
    };
    
    class Child1:Parent1
    {
     int c1;
    }
    
    class Child2:Parent1
    {
     int c2;
    }
    
    void main()
    {
     Parent1 objP1 = new Child1();
    }
    

    现在,如果在调试器窗口中看到objP1,就会看到[Child1],它是objP1的动态类型。进一步展开,可以看到属于Child1的内容。

    推荐文章