C # using namespace directive in nested namespaces

Right, I usually used the "use" of directives as follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeLib
{
  //awesome award winning class declarations making use of Linq
}

I have recently seen examples such as

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeLib
{
  //awesome award winning class declarations making use of Linq

  namespace DataLibrary
  {
    using System.Data;

    //Data access layers and whatnot
  }

}

Of course, I understand that I can use USE inside my namespace declaration. Such a thing makes sense to me if your namespaces are in the same root (they are organized).

System;
namespace 1 {}
namespace 2 
{
  System.data;
}

But what of nested namespaces? Personally, I would leave all USING ads on top, where you can easily find them. Instead, they seem to be spreading all over the source file.

Can these USING directives be used this way in nested namespaces? For example, memory management or the JIT compiler?

+3
source share
5

IL # using

, ? , JIT-?

, , .

IL- Microsoft IL Diassembler tool ( ) , , , using .

IL- , , using #. , IL extends [System.Web]System.Web.UI.Page, # : Page, using System.Web.UI; ( ).

// ***** Compiled MSIL CODE ****
// Notice all fully qualified classes throughout.
// 

.class public auto ansi beforefieldinit WebApplication1.process
       extends [System.Web]System.Web.UI.Page
{
  .field family class [System.Web]System.Web.UI.HtmlControls.HtmlForm form1
  .method family hidebysig instance void 
          Page_Load(object sender,
                    class [mscorlib]System.EventArgs e) cil managed
  {
    // Code size       95 (0x5f)
    .maxstack  4
    .locals init ([0] string strName,
             [1] string strTime)
    IL_0000:  nop
    IL_0001:  ldarg.0
    IL_0002:  call       instance class [System.Web]System.Web.HttpRequest [System.Web]System.Web.UI.Page::get_Request()
    IL_0007:  ldstr      "name"
    IL_000c:  callvirt   instance string [System.Web]System.Web.HttpRequest::get_Item(string)

IL .

, using .

, using namespace , , . , - , , , .

- , using - ( , , ). # using System.Web.UI;, ( ); using , , using, .

using, .

- IL- ( ).

+13

, System.Data, , IntelliSense System.Data, ,

- , , ...

+3

. CIL JIT-, .

: , .

+3

Copper:

  • .
  • , .
+1

, , AFAIK.

- Class1, Class2 .., . !

, , , .

0

All Articles