static void Main(string[] args) { Amplifier amplifier = new Amplifier(); while (true) { Console.WriteLine("Ampplifiers volume is: " + amplifier.Volume); amplifier.Volume = int.Parse(Console.ReadLine()); } }
static void Main(string[] args) { Amplifier amplifier = new Amplifier(); bool result; do { Console.Write("Give a new volume value (0-100) > "); string line = Console.ReadLine(); int volume = 0; result = int.TryParse(line, out volume); if (result) { amplifier.Volume = volume; } } while (result); Console.WriteLine("Press enter key to continue..."); Console.ReadLine(); }