繁体   English   中英

泛型方法中的where子句

[英]Where clause in generic method

我有一个采用2个泛型参数的泛型方法:BType和IType。 有没有一种方法可以在方法签名中定义BType必须是IType的实现?!

Edit1:这里是方法签名:

public static Expression<Func<BType, bool>> CastFunc<BType,IType>(Expression<Func<IType, bool>> customWhereClause)
public void Foo<BType, IType>(BType a, IType b) where BType : IType
public static Expression<Func<BType, bool>> CastFunc<BType,IType>(Expression<Func<IType, bool>> customWhereClause) where BType : IType

文档“对类型参数的约束”: http : //msdn.microsoft.com/zh-cn/library/d5x73970.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM