长泛型集合类型的速记声明

cam*_*ase 4 c# generics collections

我已经查看了很多示例c#泛型代码,并记得看到一个语法声明技巧,为长泛型字典类型创建了另一种简写类型.混合C#和C++就像这样:

typedef MyIndex as Dictionary< MyKey, MyClass>;
Run Code Online (Sandbox Code Playgroud)

然后允许以下用法:

class Foo
{
    MyIndex _classCache = new MyIndex();
}
Run Code Online (Sandbox Code Playgroud)

有人能提醒我哪个C#lanaguage功能支持这个吗?

Rob*_*Rob 10

就是这个,另一种形式的using指令,用于定义别名.

using MyClass = System.Collections.Generic.Dictionary<string, int>;

namespace MyClassExample
{
    class Program
    {
        static void Main(string[] args)
        {
            var instanceOfDictionaryStringInt = new MyClass();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)