using System.Collections.Generic;
private readonly Dictionary<string, string[]> hobbies = new Dictionary<string, string[]>();
public void Add(string hobbyist, params string[] hobbies)
this.hobbies.Add(hobbyist, hobbies);
public List<string> FindHobbyists(string hobby)
var hobbyists = new List<string>();
if (string.IsNullOrEmpty(hobby))
throw new Exception("Please enter hobby.");
foreach (KeyValuePair<string, string[]> h in hobbies)
foreach (string hobb in h.Value)
public static void Main(string[] args)
Hobbies hobbies = new Hobbies();
hobbies.Add("John", "Piano", "Puzzles", "Yoga");
hobbies.Add("Adam", "Drama", "Fashion", "Pets");
hobbies.Add("Mary", "Magic", "Pets", "Reading");
hobbies.FindHobbyists("Yoga").ForEach(item => Console.WriteLine(item));