DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

C# 6.0 : Use static class reference in "Using" statement

By Ashok Nalam on 25 Nov 2014 | Category: C# | Tagged: C# 6.0 visual studio 2015 .NET static using 
  Discuss Add Comment   |  
Add rating Rate this resource   

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.
  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9226  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.
 
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys