“Programs are meant to be read by humans and only incidentally for computers to execute.”
— H. Abelson and G. Sussman (in “Structure and Interpretation of Computer Programs”)
From S
olution Explorer -> Select Project -> References -> on the Grid -> Right-click -> Select Properties -> Change "Aliases" property:{ Dictionary<string, string> _names = new Dictionary<string, string> {{"Iliescu", "Ion"}, {"Basescu", "Traian"} , {null, "Dorel"}}; //ArgumentNullException Console.WriteLine(_names[null]); // ArgumentNullException Console.WriteLine(_names["Geoana"]); //KeyNotFoundException }
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 }
}