什么"明"泛型类型参数前是什么意思? [英] What does "out" mean before a Generic type parameter?

查看:155
本文介绍了什么"明"泛型类型参数前是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚看到一个不熟悉的语法,同时寻找 GROUPBY 返回类型:

I've just saw an unfamiliar syntax while looking for GroupBy return type:

public interface IGrouping<out TKey, out TElement> : IEnumerable<TElement>

MSDN来源

我知道什么呢退出平均的方法,而不是在一个泛型接口。

I know what does out mean in methods, but not in a generics interface.

这是什么退出是什么意思?

推荐答案

这是两个通用改性剂之一介绍了C#4.0(Visual Studio 2010中)。

It is one of the two generic modifiers introduces in C# 4.0 (Visual Studio 2010).

这意味着它在声明的泛型参数是协变的。

It signifies that the generic parameter it is declared on is covariant.

修改意味着它是在为逆变声明的泛型参数。

The in modifier signifies the generic parameter it is declared on is contravariant.

请参阅出来(一般修改)和的在MSDN上(一般修改)

这篇关于什么&QUOT;明&QUOT;泛型类型参数前是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆