How do you default a new class to public when creating it in Visual Studio?
visual-studio
Solution
You need to modify the file located in `C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033`.
Visual Studio 2010 (10.0) and below: 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).
After this, make sure VS rebuilds it's cache (which is just the zipfiles unzipped into directories in `C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache`) by opening a Visual Studio command shell and execute the following command:
devenv /installvstemplates
Visual Studio 2012 (11.0) and up: See the answer by @JochemKempe, as it's much easier to change this now, just by editing a single file (no unzipping or rezipping).
UPDATE: Don't forget to open your preferred text editor with admin privileges before you do any edit.
Problem
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?