-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,11 @@ ms.assetid: 4cb137b5-ec29-4c1a-adde-9f8424cb9496 | |
| --- | ||
| # 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 | ||
|
|
||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would prefer the following wording:
??
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
?? (though, "contain nested" is a duplication) |
||
|
|
||
| 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. | ||
|
|
||
| ## Example | ||
|
|
||
|
|
@@ -40,7 +42,7 @@ namespace x | |
| } | ||
| ``` | ||
|
|
||
| ## See Also | ||
| ## See also | ||
|
|
||
| - [General Structure of a C# Program](../../../csharp/programming-guide/inside-a-program/general-structure-of-a-csharp-program.md) | ||
| - [Classes and Structs](../../../csharp/programming-guide/classes-and-structs/index.md) | ||
|
|
||
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