Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _20._04._21
- {
- class Program
- {
- static void Main(string[] args)
- {
- var groups = new Dictionary<string, string>();
- groups.Add("Group1", "Song1");
- groups.Add("Group2", "Song2");
- groups.Add("Group3", "Song3");
- groups.Add("Group4", "Song4");
- groups.Add("Group5", "Song5");
- while (true)
- {
- Console.WriteLine($"Chose 1 to search by group or 2 by song");
- int num = int.Parse(Console.ReadLine());
- var input = Console.ReadLine();
- if (num == 1)
- {
- if (groups.ContainsKey(input))
- {
- Console.WriteLine($"Song is: {groups[input]}");
- }
- else
- Console.WriteLine($"Group did not found!");
- }
- else
- {
- if (groups.ContainsValue(input))
- {
- Console.WriteLine($"Group is: {groups.First(x => x.Value == input).Key}");
- }
- else
- Console.WriteLine($"Song did not found!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement