简体   繁体   中英

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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