Mariano Valenzuela
Mariano Valenzuela

Reputation: 125

Set using namespaces for all files in a folder

Is there a way to set the namespaces references for all files within a folder?

Example: All my classes in a certain folder needs to reference System.ComponentModel (and many others) and I don't want to set the references every time I create a new class.

Upvotes: 0

Views: 285

Answers (1)

Ondrej Tucny
Ondrej Tucny

Reputation: 27974

No, this is not possible. Each file represents a separate compilation unit and the C# language specification 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.

As others suggested, development tools that integrate with Visual Studio are typically used to perform such routine tasks as generating and maintaining the set of usings in each file.

Upvotes: 1

Related Questions