创建类时添加默认命名空间(Adding a default namespace when a class is created)

编程入门 行业动态 更新时间:2024-10-22 18:24:48
创建类时添加默认命名空间(Adding a default namespace when a class is created)

创建类时,默认情况下会添加这些名称空间:

using System; using System.Collections.Generic; using System.Linq; using System.Text;

我想修改现有项目或我的自定义项目模板,以便在创建新类时添加其他用法。

(而不是必须为每个类手动添加它们。当然,“CTRL +。”用于为类添加命名空间,但它不适用于扩展方法。)

These namespaces are added per default when a class is created:

using System; using System.Collections.Generic; using System.Linq; using System.Text;

I want to modify existing projects or my custom project template so that additional usings are added when a new class is created.

(Instead of having to add them manually for every class. Sure, "CTRL + ." works to add namespaces for classes, but it do not work for extension methods.)

最满意答案

转到%ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\Code\1033\Class.zip\并编辑Class1.cs和其他文件。

另请参阅%ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\..


我理解你的问题。 您需要与Visual Basic项目属性相同的行为 - Imports带来。

对于C# - 这是不可能的。

Go to %ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\Code\1033\Class.zip\ and edit Class1.cs and other files by analogy.

Also see %ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\..


I understand your question. You want the same behavior as Visual Basic project properties - Imports brings.

For C# - this is not possible.

更多推荐

本文发布于:2023-07-30 22:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1340346.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空间   Adding   default   created   class

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!