using static usage in C# 6.0

By using static directive, we can import namespace and other specific types like properties, fields, methods…etc. Once we apply the static directive, then we can use all the static members without mentioning the full qualified name. Here we discuss using static with a simple example. Open Microsoft Visual Studio and create a console application. 

using System;

using static System.Console; 

namespace CSharpUsingStatic

{

    class Program

    {

        static void Main(string[] args)

        {

            WriteLine("This is example for using static");

            ReadLine();

        }

    }

} 

As shown above we mention the System.Console namespace by using static directive. Once we declare the System.Console static directive, we can use all members of System.Console namespace without mentioning the full name. As shown in the code, we are calling WriteLine() and ReadLine() methods without mentioning the full qualified name.