对于 Microsoft 创建的类,“1”或“2”后缀意味着什么?
我最近注意到 ASP.NET 错误堆栈跟踪中的以下行
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
IDictionary`2
中的 `2
是什么意思?
I recently noticed the following line in an ASP.NET error stack trace
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
What does the `2
in IDictionary`2
mean?
I also found other classes/files named like that in the codeplex repository of ASP.NET MVC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它用于指示通用参数。例如,看一下这个反射代码:
It's to indicate generic parameters. For example take a look at this reflection code:
在 .NET 中,这是有效的:
通用参数的数量“更改”类的名称。所以你看到的数字是参数的数量(用更简单的话来说:类/接口/结构可以在泛型参数的数量上“重载”,所以你可以有
IEnumerable
和IEnumerable< ;T>
。)这些类将被称为
X`1
和X`2
,并且您会注意到名称 通用参数不会“更改”类的名称。前面两个定义之后,这个就无效了:
In .NET this is valid:
The number of the generic parameters "changes" the name of the class. So the number you see is the number of parameters (to use simpler words: classes/interfaces/structs can be "overloaded" on the number of generic parameters, so you can have
IEnumerable
andIEnumerable<T>
.)These classes would be called
X`1
andX`2
, and you would haveNote that the name of the generic parameters doesn't "change" the name of the class. After the previous two definitions, this one would be invalid:
官方的函数描述是:
如您所见,类型为
IDictioray<,>
Th '2 是采用 2 个类型的泛型的文本描述。例如,List'1是List<>。The official function description is:
As you can see the type is
IDictioray<,>
Th '2 is the textual description of a generic taking 2 Types. List'1 for example is a List<>