ellapt

T14.14.Dictionary

Feb 3rd, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Dictionary
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Make a dictionary to accept a word and translate it");
  9. Console.WriteLine("Enter a word: ");
  10. string word = Console.ReadLine();
  11. var dict = new Dictionary<string, string>(){
  12. { ".NET", "platform for applications from Microsoft"},
  13. { "CLR", "managed execution environment for .NET"},
  14. { "namespace", "hierarchical organization of classes"},
  15. { "URI", "unified resource identifier"},
  16. { "CSS", "cascading style sheet"},
  17. };
  18. try
  19. {
  20. Console.WriteLine("{0} - {1}", word, dict[word]);
  21. }
  22. catch (KeyNotFoundException)
  23. {
  24. Console.WriteLine("The word \"{0}\" does not exist in the dictioanry", word);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment