-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Update cs0116.md #9206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update cs0116.md #9206
Conversation
In C++, apart from
My guess is that:
😉 |
| # Compiler Error CS0116 | ||
|
|
||
| A namespace does not directly contain members such as fields or methods | ||
| A namespace cannot directly contain members such as fields or methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this line based on this code:
https://github.com/dotnet/roslyn/blob/1fbd48157d9196ad227f120b731d3f80b1b162de/src/Compilers/CSharp/Portable/CSharpResources.resx#L652
| A namespace cannot directly contain members such as fields or methods | ||
|
|
||
| Inside a [namespace](../../../csharp/language-reference/keywords/namespace.md), the compiler only accepts classes, structures, unions, enumerations, interfaces, and delegates. This error is often generated by developers from a C/C++ background who forget that in C#, methods and variables must be declared and defined within a struct or class. For more information, see [General Structure of a C# Program](../../../csharp/programming-guide/inside-a-program/general-structure-of-a-csharp-program.md). | ||
| A namespace can contain only other namespaces and type declarations. For more information, see the [namespace keyword](../keywords/namespace.md) article. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A namespace can contain only other namespaces and type declarations
I would prefer the following wording:
Namespaces can contain child namespace and type declarations
??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richlander then we need to define the term "child namespace". Moreover, docs rather use "nested namespace" than "child namespace"; I'm not sure if the "child namespace" is an "official" term (language spec uses "nested namespace").
What about:
A namespace can contain nested namespaces and type declarations
?? (though, "contain nested" is a duplication)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the namespace article, namespace can contain another namespace and no mention of unions.
What is "unions" in
by the way?