svetlozar_kirkov

Dictionary (Exercise)

Oct 11th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleTests
  5. {
  6.     class ConsoleTests
  7.     {
  8.         static void Main()
  9.         {
  10.             Dictionary<string, string> dictionary =
  11.                 new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
  12.             dictionary.Add(".NET", "platform for applications from Microsoft");
  13.             dictionary.Add("CLR", "managed execution environment for .NET");
  14.             dictionary.Add("namespace", "hierarchical organization of classes");
  15.             for (int i = 0; i < 10; i++)
  16.             {
  17.                 string input = Console.ReadLine();
  18.                 if (dictionary.ContainsKey(input))
  19.                 {
  20.                     string value = dictionary[input];
  21.                     Console.WriteLine("\"{0}\"",value);
  22.                 }
  23.                 else
  24.                 {
  25.                     Console.WriteLine("Error: word not found in the dictionary.");
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment