Importing individual classes in .NET
The using statement in C# and the Imports statement in VB.NET don't let you import single classes the way you can in some other languages. For some people, having an entire namespace imported into a class seems untidy - its equivalent to doing something like import java.util.* in Java.
Once you start importing entire namespaces, clashes between type names become a real possibility, so the .NET import statements support an alias feature to work around this problem. For example if you had these three imports:
using System.Windows.Forms;
using System.Threading;
using System.Timers;
then a reference to Timer would be ambiguous, because all three of those namespaces provide a class called Timer. So .NET allows you to alias classes to different names so that you give them a new short name that doesn't clash, and doesn't need to be fully qualified. For example:
using System.Windows.Forms;
using System.Threading;
using System.Timers;
using TimerControl = System.Windows.Forms.Timer;
Now any references in code to TimerControl are unambiguously resolved to System.Windows.Forms.Timer.
This alias feature can be used to import single classes by simply aliasing them to their own name. For example:
using Button = System.Windows.Forms.Button;
using Control = System.Windows.Forms.Control;
using EventArgs = System.EventArgs;
Okay so it's a little ugly, and is probably something that only the most obsessive compulsive of neat freak programmer will want to do, but if you've come to .NET from another language, and you miss the ability to import individual classes, this is one way to achieve it.


