3

Is there a setting to change where all new classes I create will automatically be Public instead of Private? I thought I remember somebody saying that you can modify a template file, but I have no clue where to look.

Mike Cole
  • 14,474
  • 28
  • 114
  • 194
  • 3
    Actually, the default accessibility is `internal`. – John Saunders Aug 14 '09 at 15:55
  • +1 to John, assuming C# (since VB defaults to Public anyway). A little thrown off by the accessor being capitalized. – Marc Aug 14 '09 at 16:01
  • 1
    @Joel - I can rebut with nothing other than, my default install of 2008 defaults VB classes to Public, unless you simply meant the absence of a modifier is Friend. – Marc Aug 14 '09 at 16:19
  • I'm looking for the same answer. It seems 99% of the time you want the class to be public. But the default is internal. It would be nice if we had the ability to make the default of "Project -> Add Class" template public. – Sam Apr 18 '22 at 12:57

3 Answers3

3

See this answer

Just to bring the information closer to the question, see the following taken from here:

I first edited the Class.cs file inside the C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip package and added the public modifier to the class.

This didn't work.

I then found this folder: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\CSharp\Code\1033\Class.zip and did the same addition on the Class.cs file in this folder and it worked.

Community
  • 1
  • 1
Marc
  • 9,254
  • 2
  • 29
  • 31
0

If you're using the wizard, I think you can specify if a member is suppose to be private or public.

As for defaults, I'm thinking that's up to the language specifications on visibilities of members. If you modify it so that it's always public or private, you can lose portability of your code even if it's system dependent.

Daniel
  • 374
  • 2
  • 5
0

If you're talking about the class code snippet, which you can change by going into Tools -> Code Snippet Manager.

Joseph
  • 25,330
  • 8
  • 76
  • 125