+ 1
How to make the console respond to a command
How do you make the console respond to like of you said "help" or "cmds" it would give you message for those user inputs
5 ответов
+ 4
Try that code again, I made a little modification.
+ 3
using System;
namespace SoloLearn
{
    class ConsoleExample
    {
        static void Main(string[] args)
        {
            String input;
            Int32 blanks = 0;
            while(true)
            {
                // Display current user
                Console.Write("user@server>");
                // Get input string
                input = Console.ReadLine();
                if(String.IsNullOrEmpty(input))
                {
                    Console.WriteLine();
                    if(blanks > 3)
                        break;
                    blanks++;
                    continue;
                }
                // Show relevant message, depending on the
                // incoming input string
                if(input.StartsWith("help"))
                    Console.WriteLine("{0}\nHow can I help you?",input);
                else if(input.Equals("quit"))
                    break;
                else
                    Console.WriteLine("\nUnrecognized command:\n{0}", input);
            }
            Console.Write("{0}\nExiting program ... bye now ...",input);
        }
    }
}
+ 3
Okay mate cool! : )
+ 1
how do I keep it from ending whenever I press enter the second time
0
I love you xd



