我读过很多关于此的文章,但我仍然不确定我是否完全理解这些定义。
以下是我认为不同术语的示例。我是否走在正确的轨道上,或者我仍然不理解这些概念。谢谢
Array<T TArray> - unbound and open.
Array<int> - bound and closed.
Array<Array<T TArray> - bound and open.
Array<Array<int>> - bound and closed.
不受约束意味着类似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
请注意,不存在这样的东西List<Dictionary<,>>
- 未绑定类型不能用作类型参数,只能直接在typeof()
。类型要么是未绑定的,要么是完全绑定的。
如果类型未绑定,则没有地方可以引用类型参数,因此“未绑定和开放”的组合是不可能的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)