Visual Studio does not create public classes by default.

Source: Internet
Author: User

When we use Visual Studio 2005/2008/2010, the created class is not public by default, which may be noticed by everyone. Some people may even feel a little worried like me.

 

I searched online with this question and found a post on stackoverflow.com (original post in English). The analysis is good. It is good to say that the default class is internal class (internal, you can hide most of the functions in the assembly, and only provide the class/interface you want to publish to the user. If you are really worried, the post also provides a method to create the default class as public, that is, ReSharper. You can also directly modify the class template of Visual Studio, the template file is located at % ProgramFiles % \ Microsoft Visual Studio 8 \ Common7 IDE \ ItemTemplates \ CSharp \ 1033 \ Class.zip.

 

After my test, direct modification to this zip file is invalid, or it may be because I tested it in the Visual Studio 2008 environment, and this method is only applicable to Visual Studio 2005, the Class in the compressed file % ProgramFiles % \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ItemTemplates \ CSharp \ Code \ 1033 \ Class.zip is modified. cs file content, no effect. Finally, I found a folder named ItemTemplatesCache under % ProgramFiles % \ Microsoft Visual Studio 9.0 \ Common7 \ IDE, % ProgramFiles % \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ItemTemplatesCache \ CSharp \ Code \ 1033 \ Class.zip \ Class. cs file content, added public in front of class, save, restart Visual Studio 2008, create a class, OK!

 

Finally, it is declared that this method is not an orthodox routine (I am not an orthodox programmer) and is not recommended for reference only.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.