Thomas Ardal

Entrepreneur and founder of elmah.io

How To Enable C# 6.0 Language Preview in Visual Studio 14 CTP 3

3426.image_3C5B41B8I attended a session at GOTO by Mads Torgersen, the program manager on the Microsoft C# team. The session where about The Future of C# and I have been wanting to dig into this myself since Visual Studio 14 CTP 3 came out. I plan on writing a number of blog posts about the new features of C# 6.0. A lot of people already wrote about this subject and there will of course be an overlap with something you have already read. I will try to give my point of view on the new features, as well as dig a little deeper into how this is implemented.

This being the first post and all, I want to start by sharing the formula for getting access to C# 6.0 inside Visual Studio. I were a bit surprised, the Visual Studio 14 CTP 3 didn’t allowed access without any configuration. VS 14 CTP 3 includes a new version of the .NET framework called vNext, which could have been in the framework selector on the New Project wizard. Either I’m missing something, or Mads didn’t tell about this little magic trip to play with the new version.

To start writing some C# 6.0 wonders, download and install Visual Studio 14 CTP 3.

Create a new Console Application:

![CreateProject](https:CreateProject

Right click the new project and Unload:

![UnloadProject](https:UnloadProject

Right click the new project and edit the csproj file:

![EditProject](https://EditProject

Locate the PropertyGroup looking like this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Add a new element to that property group named LangVersion with the value Experimental:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <LangVersion>Experimental</LangVersion>
</PropertyGroup>

Reload the project and you are ready to rock and roll.

In the next post I take a look at Auto-Properties with Initializers.

Show Comments