How do I use C# 7 in Visual Studio for MAC?

TedRogersTedRogers USMember ✭✭✭✭
edited September 2017 in General

I am getting errors for language features I used in Visual Studio 2017.

Error CS1644: Feature `declaration expression' cannot be used because it is not part of the C# 6.0 language specification (CS1644) 

I can't find a setting anywhere. How do I switch to C# 7?

Tagged:

Best Answer

Answers

  • TedRogersTedRogers USMember ✭✭✭✭

    So, if I create a brand new project I can use the 'declaration expression' feature. So, must be a project settings somewhere. I see nothing obvious in the project file.

  • TedRogersTedRogers USMember ✭✭✭✭

    I have discovered this is only happening in my iOS library project. If I change the "C# Language Version" in Project->Build->General to "Version 7" or "Latest", then I get this error:

    Error CS1617: Invalid -langversion option Latest'. It must beISO-1', `ISO-2', Default or value in range 1 to 6 (CS1617)

  • TedRogersTedRogers USMember ✭✭✭✭
    Accepted Answer

    I fixed this by removing the following lines in my iOS projects which were added to workaround this bug:
    https://bugzilla.xamarin.com/show_bug.cgi?id=56246

      <PropertyGroup>
        <CscToolExe>mcs.exe</CscToolExe>
      </PropertyGroup>
    
  • VolodymyrSavchenkoVolodymyrSavchenko UAMember ✭✭✭

    I faced this problem while updating xamarin.forms. The only problem was MonoFramework version. It was 4.8 which does not support C# 7. I changed default MonoFramework to version 5.10 and everything is fine now.

Sign In or Register to comment.