堆栈跟踪中`字符的含义 [英] meaning of ` character in stack trace

查看:67
本文介绍了堆栈跟踪中`字符的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我`字符在堆栈跟踪中的含义,如下所示吗?

Could anyone please tell me what the meaning of the ` character is in the stack trace as shown below ?

at System.ComponentModel.BindingList`1.get_ItemTypeHasDefaultConstructor()
at System.ComponentModel.BindingList`1.Initialize()
at System.ComponentModel.BindingList`1..ctor() 


我一直在搜索,但找不到解释.

谢谢,
Arwin van der Laan


I have been searching but could not find an explanation.

Thanks,
Arwin van der Laan

推荐答案

原因是有点复杂,但原因是BindingList是通用的.举个例子
The reason beghind it is a little complicated, but the reason is that BindingList is generic. Take the example
BindingList <int> foo;
BindingList <string> bar;


编译时,每个通用类型的类名称后均附加一个数字.您的课程只有一个泛型,因此类型后面必须有`1.实际类型保留一种占位符.这是因为直到运行时才能知道类型,例如可以通过反射实例化泛型
运行时,框架为泛型中的每个指定类型生成一个类.这是在使用占位符替换类型时的情况.

一旦在运行时定义,每个BindingList <int>都将成为BindingList`1.


At Compile Time the class name is appended with a number for each generic type. Your class has one generic so type so it has `1 after it. A kind of place-holder is left for the actual type. This is because the type cannot be known until runtime, for example the generic can be instaniated by reflection
At runtime the framework generates a class for each specified type in the generic. This is when the substitution of the place-holders for the type is made.

Once defined at runtime, every BindingList <int> will become a BindingList`1.

Dictionary <string, string> baz;


将被编译为Dictionary`1`2

一旦针对特定类型生成了运行时List类型,例如int,它将重新用于其他List<int>.

请参阅此内容以获得更完整(并希望更清晰的解释):
http://www.artima.com/intv/generics2.html [


Will be compiled to Dictionary`1`2

Once a runtime List type is generated for a specific type e.g. int, it will be re-used for other List<int>s.

See this for fuller (and hopefully clearer explanation):
http://www.artima.com/intv/generics2.html[^]
Very godd question BTW, most people don''t notice.

KPB: Corrected grave factual errors - apologies for the confusion. I''m not sure what I was on yesterday, but a good night''s sleep seems to have helped!


基思,谢谢你非常.
我一知道答案,就听起来很合逻辑,但是将一个字符追溯到您所解释的原理并没有引起我的注意.
甚至在MSDN上的搜索都没有提供您的答案,而是提供各种不相关的信息.

所以:thumbsup :: thumbsup :: thumbsup :: thumbsup :: thumbsup:
Keith, thank you very much.
As soon as I knew the answere it sounded very logical but to trace one character back to the principle you explained didn''t cross my mind.
Even a search on MSDN did not come up with your answere but all kinds of irrelevant information.

So :thumbsup::thumbsup::thumbsup::thumbsup::thumbsup:


这篇关于堆栈跟踪中`字符的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆