0

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.

Ondrej Tucny
  • 27,626
  • 6
  • 70
  • 90

1 Answers1

1

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.

Community
  • 1
  • 1
Ondrej Tucny
  • 27,626
  • 6
  • 70
  • 90