static void Main(string[] args) { Amp amp = new Amp(); Console.WriteLine("The starting volume is " + amp.Volume); bool result; do { Console.Write("Give a new volume > "); string str = Console.ReadLine(); int num; result = int.TryParse(str, out num); amp.Volume = num; Console.WriteLine("The volume is: " + amp.Volume); } while (result == true); }
static void Main(string[] args) { Amp amp = new Amp(); int luku; int lopetus; luku = 1; do { Console.Write("Säädä volumea välillä 0-100, lopeta kirjottamalla 'ok' > "); string line = Console.ReadLine(); luku = int.Parse(line); lopetus = int.Parse(line); amp.Volume = luku; Console.WriteLine("Volume on nyt " + amp.Volume); } while (lopetus != -1); }