Answer the question
In order to leave comments, you need to log in
C# 10. How to abandon a top-level program?
Hello.
Guys, please save me from disappointment. Yesterday I thought, for many years I thought that C# is the best PL by my standards. Today, with the release of C# 10, my perceptions have been greatly shaken.
So. We create a .NET 6 console project.
We see one single instruction:
If earlier, in C # 9, at least System had to be accessed, then in C # 10, it is not necessary at all.
It turns out that C# 10 introduces implicit using directives. Here they are defined, and in order to write the way we wrote for many years, with using, classes and an entry point, you need to dance with a tambourine. For example, create a .NET 5 project, and change it to .NET 6 in the settings.
Explain, explain, please! How to understand? Is this a forced imposition of a new coding style?
Console.WriteLine("Hello, World!");
That is, if I want to write in C # 10, but I want to write fully, and not just like that. What should I do, arrange dances so that it works?
Or how to abandon implicit directives in VS and breathe freely?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Well, it's actually convenient. and I don't see any reason. to write in the old way.
But if you really want to, you can create your own template, in which the old public static void Main will be created and without implicit uses.
This is how global usings is turned off:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
</Project>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question