Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace sorted_dictionar
- {
- class Program
- {
- static void Main(string[] args)
- {
- var phonebook = new SortedDictionary<string, string>();
- phonebook["Anna"] = "+1-555-8976";
- phonebook["Pesho"] = "+1-555-5030";
- phonebook["Bojidar"] = "+1-555-1234";
- phonebook["Nakov"] = "+359-899-555-592";
- phonebook["Nakov"] = "+359-2-981-9819"; // Replace
- Console.WriteLine(phonebook.Count);
- Console.WriteLine(string.Join(", ", phonebook.Keys));
- //Console.WriteLine(string.Join(", ", phonebook.Values));
- //phonebook.Clear();
- //Console.WriteLine(phonebook.Count);
- Console.WriteLine(phonebook.ContainsKey("Pesho"));
- Console.WriteLine(phonebook.ContainsValue("+1-555-8976"));
- foreach (string key in phonebook.Keys)
- {
- Console.WriteLine(key);
- }
- foreach (KeyValuePair<string, string> pair in phonebook)
- {
- Console.WriteLine("{0} --> {1}", pair.Key, pair.Value);
- }
- string value;
- phonebook.TryGetValue("Pesho", out value);
- Console.WriteLine(value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement