随笔分类 -  泛型

摘要:问题: When planning out my programs, I often start with a chain of thought like so: A football team is just a list of football players. Therefore, I sho 阅读全文
posted @ 2019-02-01 10:39 ChuckLu 阅读(400) 评论(0) 推荐(0) 编辑
摘要:IComparable<Student>是Student的父类,所以IComparable<Student>可以接收Student。但是在使用CompareTo方法的时候,必须传入Student,不允许传入父类IComparable<Student>。 public interface ICompa 阅读全文
posted @ 2019-01-31 20:21 ChuckLu 阅读(403) 评论(0) 推荐(0) 编辑
摘要:Define class with itself as generic implementation. Why/how does this work? 问题: I've normally been creating Prism Events used by the EventAggregator l 阅读全文
posted @ 2018-06-01 10:55 ChuckLu 阅读(252) 评论(0) 推荐(0) 编辑
摘要:variance差异 变异;变化;不一致;分歧;[数] 方差 convariance协变 仅仅用于返回值,范围扩大 out contra相反 contravariance逆变 仅仅用于函数参数,范围缩小 in 引入 https://www.codewars.com/kata/unflatten-a- 阅读全文
posted @ 2017-03-10 09:09 ChuckLu 阅读(358) 评论(0) 推荐(0) 编辑
摘要:https://msdn.microsoft.com/zh-cn/library/ee378665(v=vs.110).aspx 此方法有一共有2个,现在只讨论其中一个 public TValue AddOrUpdate( TKey key, TValue addValue, Func<TKey, 阅读全文
posted @ 2015-04-30 09:33 ChuckLu 阅读(4753) 评论(0) 推荐(0) 编辑
摘要:上面示例中的Farm<T>类以及本章前面介绍的其他几个类都继承自一个泛型类型。 在Farm<T>中,这个类型是一个接口IEnumerable<T>。 这里Farm<T>在T上提供的约束也会在IEnumerable<T>中使用的T上添加一个额外的约束。 这可以用于限制未约束的类型,但是需要遵循一些规则 阅读全文
posted @ 2015-04-23 20:20 ChuckLu 阅读(2413) 评论(0) 推荐(1) 编辑
摘要:这种错误的原因,是因为List<T>不是线程安全的。 阅读全文
posted @ 2015-02-27 17:44 ChuckLu 阅读(228) 评论(0) 推荐(0) 编辑
摘要:Covariance and Contravariance (C#) https://docs.microsoft.com/en-us/dotnet/articles/csharp/programming-guide/concepts/covariance-contravariance/ In C# 阅读全文
posted @ 2015-01-13 14:09 ChuckLu 阅读(494) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示