Using static directive in c#

Using static directive in c#

1. using static is a new kind of using clause that lets you import static members of types directly into scope.
2. This feature introduced in c# 6.0.
3. "A 'using namespace' directive can only be applied to namespaces, 'Console' is a type not a namespace. Consider a 'using static' directive instead".
4.  This will only work for members declared as static.

Here is the example of using static directive

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace usingcsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            WriteLine("usingcsharp.com");
            ReadLine();
        }
    }
}

2021-10-03