开发者

Order of imports in C#

How do you like to arrange your "using xxx" imports in C#? I got bored the other day and put the开发者_开发百科m in order from shortest to longest.

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;

Brian


I like to right click in the source code editor -> Organize Usings -> Remove and Sort

Order of imports in C#


(source: codeitwell.com)


Sort Usings


StyleCop rules are the following:

  1. System namespaces first.
  2. Alphabetical sorting.


I tend to do it in alphabetical order for the standard .NET namespaces. I always put custom/3rd part ones at the bottom with my own ones being first (in alphatical order also) e.g.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜