I followed this answer: How to enable C# 9.0-preview to enable C# 9.
I installed .NET 5 preview 5 which includes the new C# 9.
Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
I try to use C# 9:
public class Person
{
public string FirstName { get; init; }
public string LastName { get; init; }
}
with a project setting like:
<LangVersion>9</LangVersion>
but I get a compilation error:
Error CS1617 Invalid option '9' for /langversion. Use '/langversion:?' to list supported values.
I didn't find 9 in the list when run:
csc -langversion:?
The list is:
default
1
2
3
4
5
6
7.0
7.1
7.2
7.3
8.0 (default)
latestmajor
preview
latest
Then I used as suggested by this answer, but it can't help and also this.
<LangVersion>preview</LangVersion>
But I get a compilation error.
Program.cs(26,40): error CS1014: A get or set accessor expected
What did I miss to do to use C# 9 in .NET 5 preview 5?