What are the implications of using a class through an interface as opposed to using the class directly?
For example when mutating a list of integers through the IList<Int32>
interface as opposed to using the List<Int32>
class directly. Does this introduce boxing conversions, more type checks, null checks, more levels of indirection, virtual calls, reduced optimizations, prevent method inlining? If so, how can I mitigate some of that?
I am writing a library in which I intend all collection classes to be used through their interfaces. The library is for other developers who might want to use it in a high-performance setting.