为文件夹中的所有文件设置使用命名空间

Set using namespaces for all files in a folder

有没有办法为文件夹中的所有文件设置命名空间引用?

示例:我在某个文件夹中的所有 classes 都需要引用 System.ComponentModel(以及许多其他文件夹),我不想每次创建新的 [=] 时都设置引用15=].

不,这是不可能的。每个文件代表一个单独的编译单元和C#语言规范states:

A C# program consists of one or more compilation units, each contained in a separate source file.

The using_directives of a compilation unit … have no effect on other compilation units.

正如其他人所建议的那样,与 Visual Studio 集成的开发工具通常用于执行此类例行任务,例如在每个文件中生成和维护 using 的集合。