Reputation: 11395
I have a generic method that takes 2 generics parameters: BType and IType. Is there a way to define in the method signature that BType has to be a implementation of IType?!?
Edit1: here the method signature:
public static Expression<Func<BType, bool>> CastFunc<BType,IType>(Expression<Func<IType, bool>> customWhereClause)
Upvotes: 0
Views: 2203
Reputation: 13970
public static Expression<Func<BType, bool>> CastFunc<BType,IType>(Expression<Func<IType, bool>> customWhereClause) where BType : IType
Documentation "Constraints on Type Parameters": http://msdn.microsoft.com/en-us/library/d5x73970.aspx
Upvotes: 3
Reputation: 15772
public void Foo<BType, IType>(BType a, IType b) where BType : IType
Upvotes: 11