如何在Visual Studio中为C#的生成类添加默认命名空间

时间:2023-01-14 21:21:02

When I add an C# class to project, the class has some default namespaces like this:

当我向项目中添加一个C#类时,该类有一些默认的命名空间,如下所示:

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

I want to add some default namespace when I add some new class to project. For example when I added new class to project I have following generated namespace by Visual Studio:

我想在向项目中添加一些新类时添加一些默认命名空间。例如,当我向项目中添加新类时,我通过Visual Studio跟踪生成的命名空间:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyCompany.Namespace1;
using MyCompany.Namespace2;

1 个解决方案

#1


1  

You're looking for Visual Studio Item templates. You can create a new item template that contains whatever boilerplate code you'd like, then distribute that item template to your team members.

您正在寻找Visual Studio项目模板。您可以创建一个包含您喜欢的样板代码的新项目模板,然后将该项目模板分发给您的团队成员。

#1


1  

You're looking for Visual Studio Item templates. You can create a new item template that contains whatever boilerplate code you'd like, then distribute that item template to your team members.

您正在寻找Visual Studio项目模板。您可以创建一个包含您喜欢的样板代码的新项目模板,然后将该项目模板分发给您的团队成员。