Using Statement with Generics: using ISet<> = System.Collections.Generic.ISet<>

Unfortunately, the using directive does not do what you want. You can say:

using Frob = System.String;

and

using ListOfInts = System.Collections.Generic.List<System.Int32>;

but you cannot say

using Blob<T> = System.Collections.Generic.List<T>

or

using Blob = System.Collections.Generic.List

It's a shortcoming of the language that has never been rectified.


I think you're better off aliasing the namespaces themselves as opposed to the generic types (which I don't think is possible).

So for instance:

using S = System.Collections.Generic;
using I = Iesi.Collections.Generic;

Then for a BCL ISet<int>, for example:

S.ISet<int> integers = new S.HashSet<int>();

The only way you can alias a generic type is to specialize it as follows.

using IntSet = System.Collections.Generic.ISet<int>;

You can not alias an open generic type as you have done in your example:

using MySet = System.Collections.Generic.ISet<>;