C#:具有" + QUOT;在类的名字吗? [英] C# : having a "+" in the class name?

查看:129
本文介绍了C#:具有" + QUOT;在类的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类名:MyAssembly.MyClass + MyOtherClass

class name: MyAssembly.MyClass+MyOtherClass

这个问题显然是+作为分隔符,而不是traditionnal点,其功能,并找到正式文件,看看是否存在其他分隔符

The problem is obviously the + as separator, instead of traditionnal dot, its function, and to find official documentation to see if others separators exist

感谢你在前进!

推荐答案

这是只是嵌套类型的表示方式。因此,例如:

That's just the way that a nested type is represented. So for example:

namespace Foo
{
    class Outer
    {
        class Nested {}
    }
}

将创建一个类型,尽显在编译后的代码 Foo.Outer +嵌套的名称。 (所以,这就是 typeof运算(Outer.Nested).FullName 将返回,例如。)

will create a type with a full name of Foo.Outer+Nested in the compiled code. (So that's what typeof(Outer.Nested).FullName would return, for example.)

目前尚不清楚对我来说,这是否是指定的 的行为,或者只是什么Microsoft C#编译器选择使用;这是一个难以启齿的名字在你不能明确声明一个类与它在正常的C#A +,所以编译器知道它不会与任何其他冲突。 。部分C#3规范没有规定编译的名字,据我所看到的10.3.8

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.

编辑:我刚看到的 Type.AssemblyQualifiedName 规定,+ 是用来先嵌套类型名称...但它仍然不清楚是​​否真的是需要的或只是传统。

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.

这篇关于C#:具有" + QUOT;在类的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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