tags:

views:

139

answers:

4

How do you like to arrange your "using xxx" imports in C#? I got bored the other day and put them 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

+16  A: 

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

alt text

Darin Dimitrov
+1 never realised you could do that!
James
But I also set Tools | Options | Text Editor | C# | Advance | Place "System" directives first when sorting. So not quite alphabetical.
Richard
I thought you were joking at first. Learned something new today.Thanks! My question was half serious, with a touch of humor. It is after all Friday in the US.
BrianK
Good to know because it is already wednesday in the rest of the world
Marek
+3  A: 

Sort Usings

Morten Anderson
A: 

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
James
+1  A: 

StyleCop rules are the following:

  1. System namespaces first.
  2. Alphabetical sorting.
Daniel Rose