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

后端 未结 7 791
不知归路
不知归路 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:24

    To create a Public class by default for Visual Studio 2012:

    Edit this file:

    C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs
    

    To look like this:

    using System;
    using System.Collections.Generic;
    $if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
    $endif$using System.Text;
    $if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;
    $endif$
    namespace $rootnamespace$
    {
        public class $safeitemrootname$
        {
        }
    }
    
    0 讨论(0)
提交回复
热议问题