Coffee Time exercise from c# dictionary, hint 🤔
Hey i see that this quest have hint "use coffee.Keys.ToArray() inside foreach loop" but i dont understand why. I tried to solve this quest and i pass but i put coffe.Keys.ToArray() outside foreach loop how is possible to use it inside? int discount = Convert.ToInt32(Console.ReadLine()); Dictionary<string, int> coffee = new Dictionary<string, int>(); coffee.Add("Americano", 50); coffee.Add("Latte", 70); coffee.Add("Flat White", 60); coffee.Add("Espresso", 60); coffee.Add("Cappuccino", 80); coffee.Add("Mocha", 90); string[] coffeName = coffee.Keys.ToArray(); foreach(string key in coffeName) { Console.WriteLine("{0} : {1}",key,Math.Round(coffee[key]*(Convert.ToDouble(100-discount)/100),MidpointRounding.AwayFromZero)); } Console.ReadKey();