Can't change C# version in project's subfolders

Viewed 816

In my project, I've tried to tidy up the structure a bit and put all the C# classes into a separate folder (App_Code).

The problem is that it seems even if the project is set to use C# 7.1 (and .net framework 4.7)

enter image description here

Trying to create in subfolder class with newer syntax in example:

Namespace MyProject {
  public static class Class1
{     (//*****Available since C# 6.0****)
    public static string Test1 { get; } = ConfigurationManager.AppSettings["User"];

    public static int Test2 ()
    {
        string s = "10";
        int.TryParse(s, out int y);  //*****Available since C# 7.0
        return y;
    }
}

This causes a compilation error stating, that this feature requires version 6.x (or 7.x in the case of "Test2" above) instead of 5.0.

Intelisense prompts me to change the version but even after following the prompt the error persists.

Not sure if it matters, but classes in the App_Code folder have the same namespace as the ones in the rest of the project.

I use VS 2017 Pro.

0 Answers
Related