Introduction:With Visual studio versions before 2015 we can not refer static classes in 'Using' statement. With C# 6.0 (Visual Studio 2015) we can use "using" to reference static classes. The advantage is to avoid repetitive method qualification. In order to understand better we will see sample example.Example:using System.Console;
using System.Math;
namespace DotNetMirror
{
class Program
{
static void Main()
{
WriteLine("static class can be referred in using statement");
WriteLine(Pow(2, 3));
}
}
} If you observe from above code we have not appended Console class to WriteLine method each time instead we referred in using statement. Same for Pow method.
|