Access cloning massing?

I read the XNA library code and inside the type VertexPositionColor, they suppress the message CA2105:ArrayFieldsShouldNotBeReadOnlywith the rationale "The cost of executing an array clone every time it is used is too high."

public struct VertexPositionColor
{
    public static readonly VertexElement [ ] VertexElements;
}

But why copy it when used? This only happens for structures where the available property / field matters ValueType, right?

+3
source share
2 answers

I assume that they justify the fact that they are more susceptible array field, and the main reason why they do this is performance:

, , , , , private array field property, IEnumerable array , property.

. , , : p.

+3

Array.AsReadOnly ReadOnlyCollection. , O (1).

( static/ global).

- FxCop.

+1
source

All Articles