So I have VS 2022 and am trying to learn C#.
I am getting an error of Feature
'file-scoped namespace' is not available in C# 7.3 Please use language 10.0 or greater.
I found where one goes to Options>Code Style> Text Editor and change to File-scoped. Did that.
When I create my solution, I chose Blank Solution I then added an empty project using .NET framework 4.8 Next I added a code file Finally I add the following:
namespace Averages;
public static class TestClass
{
}
And I get the error. What in the world am I missing? I'm stumped. Edit: I just checked. I have .NET 7.0
You could solve this by:
namespace Averages
{
public static class TestClass
{
}
}
since Framework 4.8 doesn't allow File-scoped names, so the class should be "inside" the namespace.
But if you are learning, I would suggest don't use empty blank, syntax could be a bit different, but in learning mode this bit means a lot and you will found examples of code that often doesn't specify the syntax.
You could also try your code at Fiddle DOT NET https://dotnetfiddle.net/