我可以命名以数字开头的C#名称空间吗?
问题描述:
我在Mac上,现在无法自己尝试.
I'm on a Mac and can't try it for myself right now.
例如,它将编译:
namespace 2something.something.else { }
答
不,你不能.
名称空间名称是一个标识符,标识符的第一个字符的语法(C#4规范的第2.4.2节)是
A namespace name is an identifier and the grammar for the first character of identifiers (§2.4.2 of C# 4 specification) is
identifier-start-character:
letter-character
_ (the underscore character U+005F)
这意味着第一个字符必须是下划线或字母(包括非拉丁文字的字母,例如阿拉伯语或中文).
That means that the first character has to be an underscore or a letter (including letters in non-Latin scripts, such as Arabic or Chinese).