簡體   English   中英

C#中的導入順序

[英]Order of imports in C#

您想如何在C#中安排“使用xxx”導入? 前幾天我很無聊,把它們從最短到最長的順序排列了。

using System;
using System.Web;
using System.Data;
using System.Linq;
using System.Web.UI;
using Telerik.Web.UI;
using System.Drawing;
using System.Collections;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Collections.Generic;

布賴恩

我想在源代碼編輯器中右鍵單擊-> Organize Usings -> Remove and Sort

替代文字
(來源: codeitwell.com

StyleCop規則如下:

  1. 首先是系統名稱空間。
  2. 按字母順序排序。

對於標准.NET命名空間,我傾向於按字母順序進行。 我總是將自定義/第三部分放在底部,我自己的放在第一(也按字母順序排列),例如

using System;
using System.Drawing;
using System.Threading;
using MyNamespace.Utils
using MyNamespace.Misc
using 3rdPartyTool.Utils

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM