开发者

Can i name a C# namespace starting with a number?

开发者 https://www.devze.com 2023-03-25 00:27 出处:网络
I\'开发者_开发知识库m on a Mac and can\'t try it for myself right now. For example, will this compile:

I'开发者_开发知识库m on a Mac and can't try it for myself right now.

For example, will this compile:

namespace 2something.something.else { }


No, you can't. A namespace name is an identifier and the grammar for the first character of identifiers is:

identifier_start_character
    : letter_character
    | '_'
    ;

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).


You can't name a namespace starting with a number. You'll get a compiler error:

Identifier expected.


Nope you can't. You'll get Identifier expected error


If you really need a number in front you can write it with words

TwoSomething.something.else { }
0

精彩评论

暂无评论...
验证码 换一张
取 消