I want to create a function with C# List datatype as a parameter.
public void foo(List<Something> obj)
{
...
}
But I want to pass anykind of List type to the function, I mean, like this
List<Class1> obj1 = new List<Class1>();
foo(obj1);
List<Class2> obj2 = new List<Class2>();
foo(obj2);
Can I do something like this? How to do this? Thanks in advance
use generics.
call like
The above can be simplified further to by making use of generics type inference