我有一个引用接受泛型类型的接口(interface):
public interface IEntity<TType>
我希望将其引用传递给采用泛型类型的第二个接口(interface):
public interface IRepository<T> : IDisposable where T : IEntity, new()
我已经尝试让它工作,但到目前为止还没有成功。
有什么办法可以做到这一点吗?
最佳答案
您的界面是IEntity<T>
,不是IEntity
。这意味着您的签名 IRepository
需要反射(reflect)这一点:
public interface IEntity<TType>
public interface IRepository<T, TEntity> : IDisposable where T : IEntity<TEntity>, new()
关于c# - 具有泛型类型的接口(interface)用作第二个接口(interface)中的泛型类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35983740/