Advertisement
stanevplamen

02.8.14.DictionaryLists

Jun 13th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class DictionaryFirst
  5. {
  6.     static List<string> words = new List<string>();
  7.     static List<string> explanations = new List<string>();
  8.  
  9.     static void Splitting(string[] dictionary)
  10.     {
  11.         for (int i = 0; i < dictionary.Length; i++)
  12.         {
  13.              string[] dictsArray = dictionary[i].Split('-', '–');
  14.              words.Add(dictsArray[0].ToUpper().Trim());
  15.              explanations.Add(dictsArray[1]);
  16.         }
  17.         return;
  18.     }
  19.  
  20.     static void Testing()
  21.     {
  22.         Console.Write("Please enter a word: ");
  23.         string userInput = Console.ReadLine().ToUpper().Trim();
  24.  
  25.         for (int i = 0; i < words.Count; i++)
  26.         {
  27.             string str = words[i];
  28.             if ((userInput == str) == true)
  29.             {
  30.                 string answer = string.Format("{0} - {1}", words[i], explanations[i]);
  31.                 Console.WriteLine(answer);
  32.                 Environment.Exit(0);
  33.             }
  34.         }
  35.         Console.WriteLine("The entered word can not be found");
  36.         return;
  37.     }
  38.  
  39.  
  40.     static void Main()
  41.     {
  42.         string[] dictionary =
  43.         {
  44.             ".NET - platform for applications from Microsoft" ,
  45.             "CLR - managed execution environment for .NET" ,
  46.             "namespace – hierarchical organization of classes" ,                              
  47.         };
  48.         Splitting(dictionary);
  49.  
  50.         Testing();
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement