Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Program
- {
- public static void Main()
- {
- Dictionary<string, string> dictionary = new Dictionary<string, string>()
- {
- { "ABOBA", "Valery ABOBA is a new candidate on a president of Ruissia in 2021."},
- { "Car ", "A car (or automobile) is a wheeled motor vehicle used for transportation."}
- };
- bool isRun = true;
- string name;
- while (isRun)
- {
- name = InputName();
- if (name.Equals("Exit"))
- isRun = false;
- else
- Console.WriteLine(GetValue(name, dictionary));
- }
- }
- public static string InputName()
- {
- string name;
- Console.WriteLine("Input a name : ");
- name = Console.ReadLine();
- return name;
- }
- public static string GetValue(string name, Dictionary<string, string> dictionary)
- {
- string value;
- bool isNameValid = dictionary.TryGetValue(name, out value);
- if (isNameValid == false)
- return value = "We haven't this name in dictionary";
- return value;
- }
- }
Add Comment
Please, Sign In to add comment