长泛型集合类型的简写声明
我看过很多示例 c# 泛型代码,记得看到过一个语法声明技巧,它为长泛型字典类型创建了替代速记类型。混合 C# 和 C++ 的情况类似于:
typedef MyIndex as Dictionary< MyKey, MyClass>;
然后允许以下用法:
class Foo
{
MyIndex _classCache = new MyIndex();
}
有人可以提醒我哪种 C# 语言功能支持此功能吗?
I have looked at a lot of example c# generic code and remember seeing a syntactic declaration trick that created an alternative shorthand type for a long generic dictionary type. Mixing C# and C++ it was something like:
typedef MyIndex as Dictionary< MyKey, MyClass>;
This then allowed the following usage:
class Foo
{
MyIndex _classCache = new MyIndex();
}
Can someone remind me which C# lanaguage feature supports this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是 using 指令的另一种形式,用于定义别名。
It's this, another form of the using directive, used to define an alias.
这是如何完成的示例
Here is an example of how its done