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) to default the class to a public class?
views:
278answers:
3
+5
A:
Hi there,
You need to modify the file located in C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033. There is a zip file in there called Class.zip, unpack this, edit the file to put in your public keyword then re-pack it (make sure you backup the original).
Mitch Denny
2009-03-31 05:23:48
Thanks Mitch. I had to do a bit more, documented here, but you pointed me in the right direction: http://guyellisrocks.com/coding/defaulting-a-class-to-public-from-visual-studio/
Guy
2009-03-31 19:43:39
+3
A:
You need to change the class template, as described here.
It's slightly more involved than just editing a single file (which is what you might expect) but it doesn't sound too bad.
Jon Skeet
2009-03-31 05:23:57
+1
A:
You could either create your own project template, or modify the existing one. All these project files are template-driven, so you can alter them and/or add your own.
Check out these links:
- MSDN on VS Project Templates
- Create your own VS Project Templates
- CodeProject on VS Project Templates
Marc
marc_s
2009-03-31 05:24:53