Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

245
Visualizações
C#/.NET + VisualStudio, namespace problem

I have started learning C#/.NET/VisualStudio (2022) and have this strange problem; all the methods/classes in System and it's nested namespaces seem to be available without full path or using directives at beginning.

E.g. the following example compiles just fine:

// Program.cs
namespace MyApp
{
    internal class Program
    {
        static void Main()
        {
            Console.WriteLine("Hello World!"); //System.Console
        }

        static HttpClient client = new HttpClient(); //System.Net.Http.HttpClient
    }
}

Why this happens and can I disable this behavior somehow?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

If you are using .NET 6, this is likely from a new feature called "Implicit Usings". Depending on your project type, certain namespaces are automatically included. For example, the default console app template implicity includes the following namespaces:

  • System;
  • System.IO;
  • System.Collections.Generic;
  • System.Linq;
  • System.Net.Http;
  • System.Threading;
  • System.Threading.Tasks;

You can disable this feature by including the following in your project file:

<PropertyGroup>
   <ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>

There is further documentation on this feature and "Global Usings" in this Microsoft documentation.

over 4 years ago · Santiago Trujillo Relatório

0

You are using implicit global usings. Change the lines in your .csproj files from

<ImplicitUsings>enable</ImplicitUsings>

to

<ImplicitUsings>disable</ImplicitUsings>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda