我为我的存储库创建了此接口。 public interface IRepository<T, in TKey> where T: class
{
IEnumerable<T> Find(Expression<Func<T, bool>> predicate);
IEnumerable<T> FindAll();
T FindSingle(TKey id);
我今天的协方差和逆变阅读起来,我碰到一个职位后来在哪里乔恩斯基特在类级别解释不变性堆栈交换。他用水果的例子,为什么允许协方差在这一水平将是一件坏事: //Bad
List<Banana> bunchOfBananas = new List<Banana>();
// This would be valid if List<T> were covariant in T
List<Fruit>
我在读了方差在.NET:http://msdn.microsoft.com/en-us/library/dd799517.aspx 我遇到这条线:Variance applies only to reference types; if you specify a value type for a variant type parameter, that type parameter is inva
我有一个对变体接口的问题,我不知道解决它的最好方法。这些都是我的课: public interface IObject {
}
public interface IBigObject : IObject {
}
public interface ISmallObject : IObject {
}
public class AnObject : IBigObject {
}
pu