21

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

For example, will this compile:

namespace 2something.something.else { }
2
  • thanks all, i will accept an answer as soon as the timeout expires
    – gaz
    Aug 2, 2011 at 22:04
  • 5
    "timeout" expired over four years ago, LOL Apr 5, 2016 at 12:20

4 Answers 4

26

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

1
  • Arghhh. Too bad... My company's name starts with a number...
    – Lam Le
    Sep 4, 2020 at 4:50
4

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

Identifier expected.

2

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

0

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

TwoSomething.something.else { }

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.