I’m trying to make method that reads 3 different lists, but they should be generic.
We know that a generic list can be read like:
public void msgList<T>(List<T> readlist)
{
//do something with generic readlist, as long as T is Int, double or something else
}
But suppose you want to read 2 arguments in that method, and that one is a list of integers, and another is a list of doubles for example
public void msgList<T>(List<T> readlist, List<T> readsecondlist)
{
//do something with generic readlist and readsecondlist
}
I intend in the above that the readlist is of integers, and readsecondlist is a list of doubles, or any other generic type. Is something like this possible?
Kind regards,
>Solution :
You can have multiple generic type parameters :
public void msgList<TFirst, TSecond>(List<TFirst> readlist, List<TSecond> readsecondlist)
{
//do something with generic readlist and readsecondlist
}