Each language has its own way of dealing with things. If that were the case, I don’t even know if the question would make sense. In this case it is not only the syntax that is different, the semantics also.
In PHP the definition is valid for the whole file, until you find a new definition of namespace
. It should always be done at the beginning of the file. At least in this syntax.
Question with more details.
Documentation on the definition. About the multiple use.
Wallace says it might be different, but I didn’t see a reference to it. I hate languages that document wrong or confusingly. And I only trust the documentation (when it’s not wrong either). Using something that works but is not documented is the last thing a programmer should do.
Keys also work in PHP.
Both C# and PHP can only have types as members of namespace
.
In C# the members of a determining namespace are inside the keys that delimit it. Therefore it is possible to have more than one namespace by file.
Question with more details.
Documentation.
The correct syntax of C#:
namespace Example {
class ExampleClass {...}
}
I put in the Github for future reference.
No class name, even less method name in the name of the namespace
.
If it were to have a multi-level name it would be like this:
namespace Nome.OutroNome.MaisUmNome
But note that in the background this separation is virtual. The name is one thing. There is no one namespace
within another. It is perfect to have this namespace
without having the Nome
. Vide question linked above for more details.
I’m not sure what you want to know and the syntax of C# is wrong. You want to know about the key and the semicolon?
– Maniero
Yes what I meant was with the class within the namespace as well as in the C#
– José