Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 VS2008 的监视窗口中,我正在查看一个IEnumerable<classX>. 展开IEnumerable,一些元素的值显示为{classX}。其他出现的值为{[classX]}。有什么不同?为什么其中一些有方括号?
IEnumerable<classX>
IEnumerable
{classX}
{[classX]}
大括号内的类代表您所指对象的动态类型。例如下面的代码应该解释这个......
class Parent1 { int p1; }; class Child1:Parent1 { int c1; } class Child2:Parent1 { int c2; } void main() { Parent1 objP1 = new Child1(); }
现在,如果您在调试器窗口中看到 objP1,您会看到 [Child1],它是 objP1 的动态类型。进一步展开,您可以看到属于 Child1 的内容。