class Program { static void Main(string[] args) { //Readonly Collections are Wrapper over the Read/Write Collections ObservableCollection<string> _observableCollection = new ObservableCollection<string>() { "Mitica", "Dragomir"}; ReadOnlyObservableCollection<string > _readOnlyObservable = new ReadOnlyObservableCollection<string>(_observableCollection); _observableCollection.Add("Gigi"); //_observableCollection and _readOnlyObservable have both 3 items. List<string> _list = new List<string> { "Mitica", "Dragomir" }; List<string> _list2 = new List<string>(_list);//here is created a new list of pointers ReadOnlyCollection<string> _collection = new ReadOnlyCollection<string>(_list); _list.Add("Gigi"); //_list has 3 items // _list2 has 2 items // _collection has 3 items }
}
Niciun comentariu:
Trimiteți un comentariu