Search code examples
c#commandprompt

How do i continuously check for commands in c#?


i imagine something like this:

prompt> checkprice
price of foo is 42$
prompt>

To run multiple commands.


Solution

  • Something like:

    while(true) {
        Console.Write("prompt>");
        var command = Console.ReadLine();
    
        if (command == "command1") doSomething();
        else if (command == "command2") doSomethingElse();
        ...
        else if (command == "quit") break;
    }