The instruction should be placed before or after the name space declaration?
using
STYLECOP insists on putting instructions in the name space, which triggers the issue of potential technology impact. Understanding this slight difference can significantly improve the maintenance of the code.
If instructions are placed outside the naming space, as shown in the following example: using
File2.cs introduced a conflict named space statement: using
// File1.cs using System; namespace Outer.Inner { // ... }
instructions, resulting in potential errors.
// File2.cs namespace Outer { // ... }
using
using
It is worth noting that when the type is defined in the outer name space, not in the outer.inner, no matter what the
// File1b.cs namespace Outer.Inner { using System; // ... }
The above is the detailed content of Should C# `using` Directives Be Placed Before or After Namespace Declarations?. For more information, please follow other related articles on the PHP Chinese website!