skip to Main Content

I have created a new project in dotnet 8 / C#12. Some of the new C#12 features are well recognised by Visual studio, for example I can do this without any errors:

public class MyClass(string parameter) {...}

while it does not work in another project in dotnet 7 (so far so good).

The problem is: when I use the new syntax to create arrays/lists:

int[] a = [1, 2, 3, 4, 5, 6, 7, 8];

the IDE doesn’t recognise the syntax at all. I can compile my code correctly and run it without any errors. The error is displayed only in the IDE, it doesn’t actually exist when I run the project.

Visual Studio behaves as if it were only partially aware of the new features in C#12

How can I correct this problem, if possible without reinstalling Visual Studio? Thanks

2

Answers


  1. According to What’s new in C# 12, Visual Studio 2022 support for C#12 is updated gradually, and it is recommended that you update it to the latest version.

    The newest version of Visual Studio 2022 is version 17.8.1 which is released on Nov 21st, 2023, please try update your visual studio in Visual Studio Installer.

    Login or Signup to reply.
  2. Currently ReSharper does not fully support .NET 8 SDK – seethe .NET SDK support in JetBrains Rider doc. Current EAP version (Which is EAP 8 ATM) seems to have this issue fixed so install it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search