Aliasing with using - CSharp Custom Type

CSharp examples for Custom Type:namespace

Introduction

The format of an alias is as follows:


using aliasname = namespaceOrClassName;

For example, consider the following line:

using doit = System.Console;

To write a line to the console, you then type this:

doit.WriteLine("test");

The following code shows how to use aliasing of the System.Console class.

Demo Code

using doit = System.Console;
class AliasApp/* ww w  .  j  a v a  2s .c o  m*/
{
   public static void Main()
   {
      doit.WriteLine("Hello World!");
   }
}

Result


Related Tutorials