C # using operator placement

Possible duplicate:
If use should be inside or outside the namespace

I am looking at a code base where the author (I respect) sequentially puts the use of operators inside the namespace, as opposed to above it. Is there any advantage (more efficient GC?) For this or is it just a code style preference?

Cheers,
Berryl

+3
source share
5 answers

If you have multiple namespaces in one file, you will determine the scope only in the namespace, and not in the entire namespace in the entire file.

. ( ) "" ?

+1

, "global::", .

namspace bar {
   using foo //this may mean "using global::bar.foo OR using global::foo"

}

http://blogs.msdn.com/b/ericlippert/archive/2007/06/25/inside-or-outside.aspx?wa=wsignin1.0

+2
2008 . , .NET 4, , , , .
+1

, , .

using Bar;

namespace Foo
{
    using Bar;

    namespace Bar
    {
        class C
        {
        }

    }

    namespace Baz
    {
        class D
        {
            C c = new C();
        }
    }
}

namespace Bar
{
    class E
    {
    }
}

using , Foo. , Foo. Foo , .

. , `using global:: Bar; ', Out Bar, - D C.

0
0
source

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


All Articles