#generics
1 messages · Page 1 of 1 (latest)
No. You should use generics when it makes sense.
Oftentimes there is no need for use of Generics - or you can get away using a base class/interface instead.
ok
While this is true, it's not always optimal
interface IFoo { }
struct Foo : IFoo { }
Now if you have:
void DoSomething(IFoo foo) { }
and you call it with DoSomething(instanceOfFoo), it'll box because interfaces are reference type. But if you have
void DoSomething<T>(T foo) where T : IFoo { }
this won't box, it'll maintain the type it is
That is not always the the case, Yasa.