Although .Net 4.8 is installed and it should default to C# 7.3, asp.net still uses C# 7.0 - even in Visual Studio 2019.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@PoulBak Thanks! You are correct, C# 7.3 should by the default. This sounds like a product bug if it reproduces with new ASP.NET projects - I'm assuming old-style ASP.NET here, since you mention .NET Framework - and the appropriate avenue here would be the Visual Studio Report A Problem tool.
I'd also double-check that you don't have a props file (e.g., Directory.build.props) setting the LangVersion for you in a way that defaults to C# 7.0.
I have the version "Automatically selected based on framework version" for me which Automatically selects 7.0 and doesn't allow me to change it. How do I turn this useless "helpful" feature off? Using VS 2019 16.3.7 with .NET 4.7.2.
@cartermp I don't have a props file. This is not new, it has been like that for several years. Asp.Net uses the 'Latest Major' compiler.
@DaveSneddon The only way to get the C# 7.3 compiler in asp.net is to install 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform' from Github (and distribute it to your server). You must set the langversion to 7.3 in web.config.
@DaveSneddon @PoulBak Is your project an ASP.NET Core project, or an ASP.NET project?
/cc @danroth27 who may have more insight.
It's an asp.net classic WEBSITE (which gets compiled by the server).
I'll defer to ASP.NET folks (such as @danroth27) on whether or not the legacy website project kinds should support later C# versions, but my intuition is no, given the abundance of features that depend on types (and now runtime features with Default Interface Members) that are only available on .NET Core.
Why should asp.net websites be different than other .Net Framework? That's the question here. C# 7.3 is DEFAULT for all other .Net Framework projects.
@BillWagner mine is a ASP.NET project. @PoulBak thanks for your help, I've got it working now. I already had the latest DotNetCompilerPlatform package but the langversion was set to 'default'. Changing it to 'latest' fixed the issue. Why 'default' isn't 7.3 doesn't make sense to me.
I'm going to close this since your question seems to be answered on how to enable 7.3. Regarding defaults though, I'm unsure who you should raise this to. https://github.com/aspnet/AspNetWebStack/ perhaps?
Most helpful comment
Why should asp.net websites be different than other .Net Framework? That's the question here. C# 7.3 is DEFAULT for all other .Net Framework projects.