0

So my company is currently code based on .NET 4.5 and uses VS 2015 update 3. But I code a lot in VS 2017 .NET 4.6.1 and thought that the .NET version would keep code forced to behave the same way on two versions of VS. Not so. This is acceptable for VS 2017 full property:

private string _parm;

public string Parm
{
  get => _parm; 
  set
  {
    _parm = value;
    OnPropertyChanged(nameof(Parm));
  }
}

In VS 2015 Update 3 it can target .NET 4.6.1 and essentially the line of:

get => _parm;

has red squiggles under it from intellisense and won't build.

Is there a simple MS documentation I just am not remembering how to Google that will explain what is allowed in syntax with one VS or the other? I am asking because I just got a new book on C# 7 and like to go with new when I can for my home projects. And I hear one of the new things that I have yet to do is well typed Tuple returns as well as inline out variable declarations: https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/

But is the general rule now that the .NET version is separated from the code syntax as well allowed moving forward? I am confused because I think this is the case with .NET Core 2 as well.

user2321864
  • 2,207
  • 5
  • 25
  • 35
djangojazz
  • 14,131
  • 10
  • 56
  • 94
  • 4
    VS2015 supports C# 6. VS2017 supports C# 7. The version of .NET used has no effect upon what syntax is supported (ignoring some edge cases, such as value tuples). – David Arno Jan 10 '18 at 17:52
  • Visual Studio 2015 and 2017 uses completely different Roslyn engines in the background. Such behaviors are expected. – Lex Li Jan 10 '18 at 17:53
  • 1
    Likewise, which version of VS2017 you use affects which version of C# 7 is available to you. VS2017 Update 3 allows you to use C# 7.1; Update 5 lets you use 7.2. – David Arno Jan 10 '18 at 17:57
  • @DavidArno thanks I figured as much but was just curious. – djangojazz Jan 10 '18 at 18:39
  • If you want to stick to C#6 for certain projects then goto Project Properties -> Build -> Advanced -> and change Language version to C#6 then VS2017 should give you errors if you try to use C#7 features – user2321864 Jan 28 '18 at 08:33
  • A couple of hopefully helpful links, if not for the OP then for future readers: [What are the correct version numbers for C#?](https://stackoverflow.com/q/247621/397817) [How to use C# 7 with Visual Studio 2015?](https://stackoverflow.com/q/39461407/397817) – Stephen Kennedy Jul 15 '19 at 21:14

0 Answers0