CSharp - Namespace and Type Aliasing

Introduction

During the using declaration, you can give the namespace or the full qualified name an alias.

For example:

Demo

using C = System.Console;
class MainClass/*from www . jav  a 2s .c om*/
{
   public static void Main(string[] args)
   {
       C.WriteLine("book2s.com");
   }
}

Result

An entire namespace can be aliased, as follows:

Demo

using S = System;
class MainClass/*from   w  ww . j  a  va 2 s.  com*/
{
   public static void Main(string[] args)
   {
       S.Console.WriteLine("book2s.com");
   }
}

Result