gaz
gaz

Reputation: 221

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

I'm on a Mac and can't try it for myself right now.

For example, will this compile:

namespace 2something.something.else { }

Upvotes: 22

Views: 10769

Answers (4)

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

TwoSomething.something.else { }

Upvotes: 0

svick
svick

Reputation: 244968

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

Upvotes: 26

Mrchief
Mrchief

Reputation: 76238

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

Upvotes: 2

p.campbell
p.campbell

Reputation: 100607

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

Identifier expected.

Upvotes: 4

Related Questions