Regarding adding a namespace in the common area

we always add a namespace at the top of each form in win applications

as

using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using Business; using System.Data.SqlClient; using Business; 

and most of the namespace is common in most forms, but in asp.net there is a condition for adding a namespace only once in the web.config file. therefore, we don’t need to add it to all web forms, and this saves time. so I just need to know if there are any conditions for our winning applications. how to achieve it. thanks

+4
source share
2 answers

No, there are no applications for WinForm since ASP.NET applications use the <namespaces> section of web.config. Also note that this only applies to .aspx pages, not the code behind C #. In C #, you need to add the correct using statements to bring in the types you want to use in scope.

+4
source

One way is to add a standard using directives to common templates.

You do not specify which version of visual studio you are using, but in VS2010 you can find the templates in:

 C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip 

Modify the Class.cs file in zip to include the ones you need by default.

The only drawback to this is that it is designed for each machine - so you will need to do this on every development computer, although I suppose you could run it using Active Directory (this is a question for serverfault.com).

I believe that command templates can also be customized - but this is not what I tried. Further information is available here:

http://msdn.microsoft.com/en-us/magazine/cc188697.aspx

+2
source

All Articles