2011-07-14 52 views
4

我們一直在贏應用在各種形式的頂部添加命名空間關於在公共區域增加命名空間

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; 

,最命名空間是常見的大多數形式,但在asp.net有是在web.config文件中只添加命名空間一次的規定。所以我們不必將其添加到所有網絡表單中,並節省了時間。所以我只需要知道是否有我們的勝利應用程序的任何相同的規定。如何實現它。感謝

+1

不認爲這是可能的,誠實的。 – Tigran

+0

@ user728750:不是我所知道的,但它是一個不錯的主意。 –

回答

4

沒有,沒有任何排序規定您的WinForm的應用,因爲是使用在web.config中<namespaces>部分ASP.NET應用程序。另請注意,這僅適用於.aspx頁面,而不是C#後面的代碼。在C#中,您必須添加適當的using語句才能將要使用的類型納入範圍。

2

一種方法是將標準使用指令添加到通用模板中。

你沒有提到你正在使用的Visual Studio中的版本,但在VS2010,你可以找到在模板:在zip

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

更改Class.cs文件包括usings你默認情況下需要。

唯一的缺點是它是每臺機器 - 所以你需要在每臺開發人員計算機上執行它 - 儘管我敢說你可以用Active Directory(這是serverfault.com的問題)推出它。

我相信也可以建立團隊模板 - 但這不是我已經嘗試過的。更多信息可在這裏:

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