Type parameters vs. generics
Absolutely: when you don't know the type until execution time. For example:
foreach (Type t in someAssembly.GetTypes())
{
Foo(t);
}
Doing that when Foo
is generic is painful. It's doable but painful.
It also allows the parameter to be null
, which can be helpful in some situations.