[英]Calling a method with Generic signature and parameter
I have the following signature which has a generic type and parameter as below: 我有以下签名,具有以下通用类型和参数:
List<T> GetMyList<T>(T filter);
The filter type is different from the list type. 过滤器类型不同于列表类型。 I am trying to call like this:
我试图这样打电话:
var myList = repo.GetMyList<List<items>>(filter);
I am not sure how to specify the type of 'filter' in the method call. 我不确定如何在方法调用中指定“过滤器”的类型。 Is this possible?
这可能吗?
如果类型不同,则需要具有2个通用类型,如下所示:
public List<T1> GetMyList<T1, T2>(T2 filter);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.