I'm trying to get my head around this. What's the difference between these 4?
1. private ObservableCollection<T> _myObservableCollestionOfTs
2. private readonly ObservableCollection<T> _myObservableCollestionOfTs
3. private ReadOnlyObservableCollection<T> _myObservableCollestionOfTs
4. private readonly ReadOnlyObservableCollection<T> _myObservableCollestionOfTs
Thank you for any help :)
A mutable reference to a mutable collection. The collection's elements can be changed, and the reference pointing to the collection can be reassigned to a different collection or set to null.
An immutable reference to a mutable collection. The collection's elements can be changed, but the reference pointing to the collection cannot.
A mutable reference to an immutable collection. The collection's elements cannot be changed, but the reference can be pointed to a different collection.
An immutable reference to an immutable collection. Neither the collection's elements nor the reference pointing to the collection can be changed.
Read-only collections are simply wrapper classes around ordinary collections that prevent modification of the collection's elements; see the remarks here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.