Steven Giesel 4/26/2022

ReadOnlyCollection is not an immutable collection

Read Original

This technical article clarifies that a ReadOnlyCollection in C# is not immutable; it's a read-only view of a mutable underlying collection. The post demonstrates with code examples how modifying the original list changes the ReadOnlyCollection, contrasts it with truly immutable types like ImmutableArray, and discusses the performance trade-offs (O(1) vs. O(n) operations).

ReadOnlyCollection is not an immutable collection

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser