The Hidden C# "Typedef"

I’ve just seen a blog entry about C# generics, concerning C#’s lack of typedefs. Actually, C# has a way of aliasing classes, using the using directive:

using IntList = System.Collections.Generic.List<int>; 

Quite simple. This has been there since version 1, but it wasn’t useful until now.

Creating empty classes as suggested in the above link is a bad idea, in my opinion. You’d have to maintain additional types, and it can be awkward for interoperating assemblies (think of two assemblies defining different “alias classes” for the same type.)

Edit: Also see this post at Eric Gunnerson’s blog.