有一个“”x2B;”在班级名称中?
类名:MyAssembly.MyClass+MyOtherClass
问题显然是用+
作为分隔符,而不是传统的点号,其作用,又去找官方文档,看看其他分隔符是否存在。
Class name: MyAssembly.MyClass+MyOtherClass
The problem is obviously the +
as separator, instead of traditionnal dot, its function, and to find official documentation to see if others separators exist.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是嵌套类型的表示方式。例如:
将在编译的代码中创建一个全名为 Foo.Outer+Nested 的类型。 (例如,这就是 typeof(Outer.Nested).FullName 会返回的内容。)
我不清楚这是否是指定的行为,或者只是 Microsoft C# 的行为编译器选择使用;这是一个“难以形容”的名称,因为您无法在普通 C# 中显式声明带有 + 的类,因此编译器知道它不会与其他任何内容发生冲突。据我所知,C# 3 规范的第 10.3.8 节并未规定编译名称。
编辑:我刚刚看到
Type.AssemblyQualifiedName< /code>
指定“+”用于嵌套类型名称之前...但仍不清楚这是否实际上是必需的或只是常规的。
That's just the way that a nested type is represented. So for example:
will create a type with a full name of
Foo.Outer+Nested
in the compiled code. (So that's whattypeof(Outer.Nested).FullName
would return, for example.)It's not clear to me whether this is specified behaviour, or just what the Microsoft C# compiler chooses to use; it's an "unspeakable" name in that you couldn't explicitly declare a class with a + in it in normal C#, so the compiler knows it won't clash with anything else. Section 10.3.8 of the C# 3 spec doesn't dictate the compiled name as far as I can see.
EDIT: I've just seen that
Type.AssemblyQualifiedName
specifies that "+" is used to precede a nested type name... but it's still not clear whether or not that's actually required or just conventional.这就是编译器在元数据中使用的内容来表示嵌套类。
即
会被视为
在元数据中
This is what the compiler uses in the metadata to represent a nested class.
i.e.
would be seen as
in the metadata