Что было бы практическим преимуществом использования generics vs interface в этом случае:
void MyMethod(IFoo f)
{
}
void MyMethod<T>(T f) : where T : IFoo
{
}
т.е. что вы можете сделать в MyMethod<T>
, что вы не могли бы использовать в универсальной версии? Я ищу практический пример, я знаю, что такое теоретические различия.
Я знаю, что в MyMethod<T>
T будет конкретным типом, но тем не менее я буду использовать его только как IFoo внутри тела метода. Итак, каково было бы реальное преимущество?