Since many years, we use generic collections most of the time. Sometimes we really do need a collection of anything (well, usually only a few different things but with no common base class). For such circumstances we can use either IList
or the generic IList<object>
as type for method arguments and properties.
Is there any reason to prefer one over the other? Performance characteristics?
Personally, I'm leaning towards IList<object>
, as I think this makes it more clear that we really do accept "anything". When a parameter is typed as IList
we cannot immediately tell if this method do accept anything, or if the lack of generics is due to history or sloppy coding.