0

I'm using .Net 7.0, and I'm trying to write a console application in Visual studio. In old versions it was possible to add some namespaces by 'using' primitives. But in this version there's no need to add any using primitives. For example it doesn't need to add 'using System' or 'using System.Linq'. I want to know that which namespaces has added to this 'Program.cs' class and how to add or remove any namespace to this list?

Thanks.

HosseinSedghian
  • 383
  • 2
  • 15
  • The feature is called implicit usings or sometimes referred to as global usings. See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview#implicit-using-directives for the defaults and how to edit them. – Ralf Apr 21 '23 at 10:55
  • [This link](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview#implicit-using-directives) in duplicate describes imported namespaces based on used SDK. – Guru Stron Apr 21 '23 at 10:57

1 Answers1

1

According to this resource, once you've built your app, look in obj/Debug/net7.0 for a file called ***.GlobalUsings.g.cs.

This was evidently added in .NET 6, not .NET 7.

AKX
  • 152,115
  • 15
  • 115
  • 172
  • 1
    Here is the official doc for [imported implicit usings](https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview#implicit-using-directives) – Guru Stron Apr 21 '23 at 10:58