10
votes

I have written a following code for one of my C# 6.0 Sample application. It was working fine earlier with Visual Studio 2015 Preview. But now when I have downloaded the newest version of Visual Studio 2015 which launched before some time.(http://blogs.msdn.com/b/bharry/archive/2015/01/16/visual-studio-2015-ctp-5-is-available.aspx) it stopped working.

Following is a code for that.

using System.Console;

namespace StaticClassUsing
{
     class Program
     {
        static void Main(string[] args)
        {
              WriteLine("With using statement");
        }
     }
 }

Now when you run this application in Latest Version of Visual Studio 2015 its giving error like following.

enter image description here

I have tried setting up language to C# 6.0. Is Microsoft is moving away with this feature?

Any help will be appreciated.

1
Are you sure that you had using System.Console; and not using Console = System.Console; in your program's source? As far as I know this has never been a language feature. - Dai
Yes, I am sure. I have used my examples for my blog - dotnetjalps.com/2014/12/… and you can find that code on github at following place- github.com/dotnetjalps/Csharp6NewFeatures There are few other features also not working - Jalpesh Vadgama
I haven't seen anything about them removing it, however they do note in the release notes that it is subject to change, and I saw this update note: "The syntax will be more different from current using clauses – it will have the keywords using static." source - tophallen
That was the feaure of C# 6.0 you can use using statement with static and earlier version of visual studio 2015 it was working fine. - Jalpesh Vadgama
Works for me with VS 2014 CTP - Sriram Sakthivel

1 Answers

24
votes

This was recently changed from the syntax:

using System.Console;

to

using static System.Console;

See https://github.com/dotnet/roslyn/commit/b49f841bdeeb0b620240d2435f5a0665012f6fce