1개월 전 · Jul 18, 2026 12:12 AM
Why ReadOnlyCollection<T> is not truly immutable and how ImmutableArray<T> fixes it:
ReadOnlyCollection<T>is just a wrapper around an existing list. If another thread modifies the underlyingList<T>, theReadOnlyCollectionchanges underneath you (not thread-safe!).ImmutableArray<T>is areadonly structwrapping a private immutable array. It is 100% thread-safe, has zero wrapper object heap allocation, and allows lock-free reads across all threads without risk of modification.