Does C# Support Project-Wide Default Namespace Imports Like VB.NET?

No there is no way. C# does not support the concept of project level imports or project level namespaces.

The only thing you can do is alter the item template you are using (Class.cs or Code.cs) to have the namespaces you would like. These files are located under the following directory

%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\itemtemplatescache\CSharp\Code\1033

Under here you should see a Class.zip and Code.zip directory each with a .cs file under them. This is the template file used when you do an “Add New Item” operation in Visual Studio. You can change these to meet your needs and have the default namespaces you’d like.

A slightly easier solution though is adding a per-user code file for the particular project you’d like. Simply create a code file you want to be the template for your application and then place it in the following directory.

C:\Users\YourUserName\Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#

This file will now show up whenever you do a “Add New Item” operation.

Leave a Comment