0
votes

The following blog post on MSDN says that we have to set the langversion to 'experimental' to get C# 6 to work: http://blogs.msdn.com/b/csharpfaq/archive/2014/06/03/visual-studio-14-ctp-now-available.aspx

However when using Visual Studio 2015 I'm getting the following error:

Invalid option 'experimental'.

Is this a bug?

1
VS 2015 is not officially out yet, so there's always the chance that things are changing around a little. I suggest you add the ctp tag to your question, to avoid confusion for future readers (when VS 2015 will be out). - stakx - no longer contributing
Btw. last time I played around with the VS 2015 pre-release, there was no need to turn on any experimental switch; the newest, experimental language features worked right out of the (proverbial) box. - stakx - no longer contributing
The beta releases are coming fast and furious, anything you read is outdated in a hurry. Basic conclusion to draw is that you now have a CTP version that isn't "experimental" anymore. - Hans Passant
And a third note, contrary to what you're saying, the post that you're linking to is not from MSDN, but from some other blog. - stakx - no longer contributing

1 Answers

3
votes

Visual Studio 2015 comes with C# 6.0. You don't need any extra settings, that was true in older versions.

You should also note that Parameterless Struct Constructors didn't make it to C# 6.0.

This can be seen with a TryRoslyn example (which operates on the latest version of Roslyn).

This struct:

public struct Point
{
    public int x;
    public int y;

    public Point()
    {
        this.x = 0;
        this.y = 0;
    }

    public Point(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}

Gives this warning:

Error CS0568: Structs cannot contain explicit parameterless constructors