Generics 打开、关闭、绑定和未绑定泛型类型

Generics 打开、关闭、绑定和未绑定泛型类型,generics,Generics,我读过很多关于这个的帖子,但我仍然不确定我是否完全理解这些定义 以下是我认为不同术语的示例。我是在正确的轨道上,还是我仍然不理解这些概念。谢谢 Array<T TArray> - unbound and open. Array<int> - bound and closed. Array<Array<T TArray> - bound and open. Array<Array<int>> - bound and closed.

我读过很多关于这个的帖子,但我仍然不确定我是否完全理解这些定义

以下是我认为不同术语的示例。我是在正确的轨道上,还是我仍然不理解这些概念。谢谢

Array<T TArray> - unbound and open.
Array<int> - bound and closed.
Array<Array<T TArray> - bound and open.
Array<Array<int>> - bound and closed.
数组-解除绑定并打开。
数组绑定并关闭。

数组Unbound的意思类似于
typeof(Dictionary)
。未绑定类型仅对反射感兴趣,只能在
typeof()
中使用,不能在任何其他上下文中使用。 所有未绑定类型都是闭合类型,不可能组合“未绑定和打开”

假设T是当前类/方法的类型参数:

Dictionary<,> - unbound and closed
Dictionary<string, int> - constructed and closed
Dictionary<int, T> - constructed and open
Dictionary<string, List<T>> - constructed and open
NonGenericClass - bound and closed
字典-未绑定和关闭
字典构造和关闭
词典构造与开放
词典构造与开放
非广义类的界与闭
请注意,没有“列表”
——未绑定类型不能用作类型参数,只能直接在
typeof()中使用。类型要么是未绑定的,要么是完全绑定的。

如果一个类型是未绑定的,那么它就没有地方可以引用类型参数,所以“未绑定和打开”组合是不可能的。

谢谢Daniel。非常有用。