Aliases with Using in C#

April 29th, 2006
[ Geek ]

Wish I’d known about this before, now I do. Let’s say you need to refer to Custom.Session and NotCustom.Session within the same class. Refering to Session alone is clearly ambiguous but it’s annoying, and clutters the code, to have to type those full paths in every reference. C# allows you to alias them in the using call:

using NotCustom;
using CustomSession = Custom.Session;
Be Sociable, Share!