1
Reply

Hello, I like to work with a while and a switch to type commands to call functions I have a functi...

Arian Zand

Arian Zand

Nov 2 2012 1:04 PM
902

Hello,

I like to work with a while and a switch to type commands to call functions

I have a function decrease

public void Decrease(int input)         {             input -= 5;             Thread.Sleep(100);             Console.WriteLine("Input is now:" + input+"\n");         }

And a function increase

 public void Increase(int input)         {             input += 5;             Thread.Sleep(100);             Console.WriteLine("Input is now:" + input + "\n");         }


And my Main

static void Main(string[] args)         {            CommandTest c = new CommandTest();              string Command = Console.ReadLine();             while (Command != "stop")             {                 switch (Command)                 {                     case "start":                         c.Decrease(50);                         break;                     case "stop":                         c.Increase(50);                         break;                      default:                         Console.WriteLine("Wrong input!");                         break;                 }             }

When I type 'start' on my cmd It always repeats the functions 'Decrease' -> that's OK:-)

But When I type 'Stop' it doesn't call my function 'Increase', why not?

Is there something wrong with the statement of my while?

What's wrong here ?

Thnx!

Answers (1)