Advertisement
Comrade_Sharikov

Dictionary

Jun 10th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp1
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Dictionary<string, string> names = new Dictionary<string, string>();
  11.  
  12.             names.Add("Петров", "Андрей Максимович");
  13.             names.Add("Алексеев", "Иван Борисович");
  14.             names.Add("Сафронов", "Сергей Игоревич");
  15.             names.Add("Пушкин", "Александр Владимирович");
  16.             names.Add("Рыжов", "Матвей Григорьевич");
  17.  
  18.             Console.WriteLine("Введите фамилию ученика");
  19.             string userInput = Console.ReadLine();
  20.  
  21.             if (names.ContainsKey(userInput))
  22.                 Console.WriteLine($"ФИО ученика: {userInput} {names[userInput]}");
  23.             else
  24.                 Console.WriteLine("Фамилия не найдена");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement