Using the readonly
keyword on a
field means it can’t be changed after initialization. However, that’s only partly true when applied to collections or arrays. The
readonly
keyword enforces that another instance can’t be assigned to the field, but it cannot keep the contents from being updated. In
practice, the field value can be changed, and the use of readonly
on such a field is misleading, and you’re likely not getting the
behavior you expect.
This rule raises an issue when a non-private, readonly
field is an array or collection.