using statement with static class is not working in visual studio 2015 CTP

被刻印的时光 ゝ 提交于 2019-12-21 04:02:41

问题


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.

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

Any help will be appreciated.


回答1:


This was recently changed from the syntax:

using System.Console;

to

using static System.Console;

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



来源:https://stackoverflow.com/questions/28123349/using-statement-with-static-class-is-not-working-in-visual-studio-2015-ctp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!