创建类的文件夹时,更改默认命名空间(Visual Studio中) [英] Change Default Namespace when creating Class in Folder (Visual Studio)

查看:930
本文介绍了创建类的文件夹时,更改默认命名空间(Visual Studio中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能改变,当您创建在Visual Studio中一个新的类使用的默认命名空间



背景:我的解决方案有一个项目MyCompany.MyProject.Domain其中我有一个文件夹示范基地(LINQ)与子文件夹扩展,我把所有局部类扩展。

  MyCompany.MyProject.Domain 
+示范基地(LINQ)
+扩展
- Order.cs
- Trace.cs

当我在那里建立新的cs文件,命名空间被设置为MyCompany.MyProject.Domain.Model_Base\_\_Linq\_\_.Extensions,我只希望它是MyCompany.MyProject.Domain.Model虽然。



我怎样才能改变这种默认行为


解决方案

有4所学校想到这里的:<? / p>


  • 编辑它手动

  • 忍受它

  • 变化类模板(或出口第二类模板)

  • 创建子目录之外的文件,然后在

$ b $拖动b

我倾向于使用第4;它比编辑不是改变模板


更快,少些麻烦

How can I change the default namespace used when you create a new class in Visual Studio?

Background: My solution has a project MyCompany.MyProject.Domain in which I have a folder "Model Base (Linq)" with a subfolder "Extensions" where I keep all partial class extensions.

MyCompany.MyProject.Domain
   + Model Base (Linq)
        + Extensions
           - Order.cs
           - Trace.cs 

When I create a new .cs file in there, the namespace gets set to MyCompany.MyProject.Domain.Model_Base\_\_Linq\_\_.Extensions, I only want it to be MyCompany.MyProject.Domain.Model though.

How can I change this default behavior?

解决方案

There are 4 schools of thought here:

  • edit it manually
  • live with it
  • change the class template (or export a second class template)
  • create the file outside the sub-directory, then drag it in

I tend to use the 4th; it is quicker than editing, and less hassle than changing the templates

这篇关于创建类的文件夹时,更改默认命名空间(Visual Studio中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆