I recently did some rough performance measuring on List<>
vs []
for an array of small structures. System.Array seemed to win hands down so I went with that.
It's only just dawned on me that System.Array contains object types, so surely filling it with structures would cause boxing to occur?
However, the MSDN entry for System.Array states:
In the .NET Framework version 2.0, the Array class implements the
System.Collections.Generic.IList<T>
,System.Collections.Generic.ICollection<T>
, andSystem.Collections.Generic.IEnumerable<T>
generic interfaces. The implementations are provided to arrays at run time, and therefore are not visible to the documentation build tools. As a result, the generic interfaces do not appear in the declaration syntax for the Array class, and there are no reference topics for interface members that are accessible only by casting an array to the generic interface type (explicit interface implementations).
Does this mean that boxing does not occur after all? (And would explain my performance results)