This is similar to C# – Multiple generic types in one list
However, I want a generic method to accept a List of objects that all implement the same interface.
This code gives the error that there is no implicit reference conversion.
public interface ITest { }
public class InterfaceUser : ITest { }
public class TestClass
{
void genericMethod<T>(T myList) where T : List<ITest> { }
void testGeneric()
{
genericMethod(new List<InterfaceUser>());
}
}
Can this be done?
Define
TasITestand take aList<T>as argument