2
public void Function<T>(params T[] list)
    where T : BaseT
{
    foreach (var elem in list)
        Function(elem);
}

public void Function<T>(T elem)
    where T : BaseT
{
    // stuff
}

And now when I call it with T1 and T2 which are derived from BaseT :

Function(new T1()); // this calls Function(elem) method
Function<BaseT>(new T1(), new T2()); // this call Function(list) method

So why doesn't the first call work like the second, in the sense that it should call the Function(list) method with one parameter? How does the params keyword influence the code?

0 Answers0