Visual C# 2010 Express:为新类指定默认访问修饰符?
每当我使用 Visual Studio 2010 Express C# 创建新类时,它都会创建不带访问修饰符的新类。十分之九我希望我的新课程公开。如何让 Visual Studio 默认创建带有“public”修饰符的空类模板?
Whenever I create new classes using Visual Studio 2010 Express C# it creates them with no access modifier. 9 times out of 10 I want my new classes to be public. How can I have Visual Studio create empty class templates with the "public" modifier by default?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
诀窍是创建一个名为 Class 的新项目模板。然后当你执行添加>时新建类,将默认选择您的模板而不是内置的类模板。 (我不确定这种行为是否得到保证,但它可以在我的机器 (TM) 上运行。) 要创建模板:
现在执行添加>类,您应该会看到默认使用您的类模板,而不是内置模板。
The trick is to create a new item template named Class. Then when you do Add > New Class, your template will be selected by default rather than the built-in Class template. (I am not sure if this behaviour is guaranteed but it Works On My Machine (TM).) To create the template:
Now do an Add > Class and you should see your Class template being used by default instead of the built-in one.
您可以定义您自己的项目模板 。
Visual Studio 模板
Express Edition 也支持它们:创建 Visual Studio Express 模板
You can Define Your Own Item Templates.
Visual Studio Templates
They are supported in the Express Edition as well: Creating Visual Studio Express Templates
文章如何在 Visual Studio 2008 或 2010 中修改 C# 的默认新类模板? 应该有所帮助。
The article How to modify the default new class template for C# in Visual Studio 2008 or 2010? should help.