Where to use using statements in a C # .cs file

DUPE: Should I use "operators" inside or outside the namespace?

If I add a new class using Visual Studio to the project, it will add all using statements in front of the namespace, but for the same project, FxCop says it puts namespaces in the namespace. What is the best coding style?

+3
source share
5 answers

, . , , , Visual Studio , .

, , , , .

+1

" ", .
,

0

. FxCop Microsoft. , Visual Studio .

0

Using directives brings names into scope. Given this definition, and also noting that you can have multiple namespaces in a single file, it makes sense if the names executed by the using directive apply only to a specific namespace, since group names are a namespace.

Ignore the fact that FxCop probably complains about multiple namespaces per file.

But in this case, I prefer VS by default. Why do extra work for yourself?

0
source

Source: https://habr.com/ru/post/1702491/


All Articles