ReadOnlyCollections

suggest change

Versions

ReadOnlyCollection<T> on this page applies to .NET Framework 2.0 through 4.6.2.

Remarks

A ReadOnlyCollection provides a read-only view of an existing collection (the source collection).

Items are not added to or removed from a ReadOnlyCollection directly. They are added to and removed from the source collection, and the ReadOnlyCollection reflects those changes.

The number and order of elements in a ReadOnlyCollection cannot be changed through that wrapper. The properties of the elements can still be changed, and their methods can still be called.

Use a ReadOnlyCollection when callers should be able to view the collection but not modify it, while your code can still modify the source collection.

See Also

ReadOnlyCollections vs ImmutableCollection

There is no BCL type named ImmutableCollection. Types such as ImmutableList<T> live in the System.Collections.Immutable NuGet package. An immutable collection cannot be changed in place: adding, removing, or reordering returns a new collection, and the original still has the same elements in the same order. A ReadOnlyCollection cannot be edited through the wrapper, but the source collection can still add, remove, and reorder elements.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents