Using static members - C# 6 Language New features

In this article we are going to explain the use of static in C# 6. We already know the use of static member in previous version of C#. But in C# 6 update you will know the very effective use of "Static".
What is Static ?
Static is keyword use to make your class , method or variable accessible in another class without creating any instant or object.

In previous version of C#, If we want to use any static method we must write "ClassName.Method". Here we take example of C# inbuilt static method Console.WriteLine(). Whenever we use WriteLine() method we must write a class name before.
public class Foo
{
    public void DoSomething()
    {
        Console.WriteLine("Using Static Before C# 6");
    }
}
If we use WriteLine() directly it will throw an error "The name WriteLine does not exist in the current context".

In C# 6, Just add using the System. Console and you will able to use Console class method directly without using of class names.
using System.Console;
public class Foo
{
    public void DoSomething()
    {
        WriteLine("Using Static After C# 6");
    }
}
Take a look in our example, we moved Console static class in to the namespace and it's still valid and after running this code we got following article.

Don't forgot to read my C# 6 language new features series