The using Directive - CSharp Custom Type

CSharp examples for Custom Type:namespace

Introduction

The using directive imports a namespace, so that you can refer to types without their fully qualified names.

The following imports the previous example's Outer.Middle.Inner namespace:

namespace Outer
{
  namespace Middle
  {
    namespace Inner
    {
      class Class1 {}
      class Class2 {}
    }
  }
}


using Outer.Middle.Inner;

class Test
{
  static void Main()
  {
    Class1 c;    // Don't need fully qualified name
  }
}

Related Tutorials