0

Is it possible to remove both namespace {} from Visual Studio template so the class will look like this when generated:

namespace X;
public class Class1
{
}

I changed the file content from \Microsoft Visual Studio\2022\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class and now it looks like this

namespace $rootnamespace$;
class $safeitemrootname$
{
}

but when creating a new class it looks like this

namespace X
{
    public class Class1
    {
    }
}
  • Yes, but there are _dozens_ of almost-identical `.cs` files in the template directory, so I think you edited a file template used by a different project-type (e.g. C# ASP.NET Core and C# Console Projects use different item templates), so you'll need to edit **all** of them. Have fun. – Dai Nov 27 '21 at 18:24
  • I only want to change it for class and interface. Does it matter? – alex clapou Nov 27 '21 at 18:31
  • Yes, this helped me. Thank you – alex clapou Nov 27 '21 at 20:13

0 Answers0