How do you default a new class to public when creating it in Visual Studio?

后端 未结 7 849
不知归路
不知归路 2020-11-28 02:54

When I right click in the Solution of a C# Visual Studio project and select Add... > Class... it creates a class without a public modifier. How do I get Visual Studio (2008)

7条回答
  •  时光说笑
    2020-11-28 03:02

    In addition of JochemKempe great answer, here is how to do it for the .NET core templates.


    .NET Core

    Instead of editing the templates inside the \CSharp\ directory, you need to edit the ones inside \AspNetCore\.

    VS2019 (Enterprise): C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ItemTemplates\AspNetCore\Code\1033\Class\Class.cs

    VS2019 (Professional): C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ItemTemplates\AspNetCore\Code\1033\Class\Class.cs

提交回复
热议问题