Reputation: 75
I just recently started back into C# and installed Visual Studio 2019 on APRIL 14,2021.
I started a new .NET Core Windows Forms App targeting Core Framework 4.7.2
I was starting to do some work with basic database connections:
I used the following:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
In my Form_1 Load section:
using SqlCommand command = new SqlCommand(AMZN_select, AMZN_Connection);
I get an error:
"Feature 'usings declarations' is not available in C#7.3. Please use language 8.0 or greater"
So my question: I installed this version a few days ago in 2021. We are on version 9.0 I think for C#. I was assuming that a new project in 2021 would automatically taregt at least C#8, not C#7.3.
When I search the Google machine for this error I see people editing configuration files? Seriously? Thats how you target the correct C# version in a completely new project? I am willing to start from scratch and restart the project and open a new project but can I target the LATEST available C# version from the creation of the project. Again, I thought targeting a 4.xx framework would automatically get me C# version 8.0
What am I missing.
If I have to edit a config file can someone tell me what file I have to edit. I just can't believe the IDE allows me to create a project, get started and then tell me I am not targeting a current version of C#.
Again, I am returning to Visual Studio after 5 years but I don't remember having this issue back then.
OK heres what I found:
When I created the app I used:
Apparently you have to use:
I read the descriptions of the two and they seem virtually identical but apparently not.
One allows me to use:
'using'
UPDATE:
So the choice is grayed out depending on how you began the project.
Upvotes: 0
Views: 1963
Reputation: 66
C# 7.3 is the last C# version targeting .NET Framework. Newer language versions are only available for .NET Core 3, .NET 5 or .NET Standard 2.1.
See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version .
Upvotes: 1