+ 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

20th Dec 2017, 3:23 PM
Aerial
Aerial - avatar
5 Answers
+ 4
Try that code again, I made a little modification.
21st Dec 2017, 11:32 PM
Ipang
+ 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); } } }
20th Dec 2017, 7:07 PM
Ipang
+ 3
Okay mate cool! : )
20th Dec 2017, 7:11 PM
Ipang
+ 1
how do I keep it from ending whenever I press enter the second time
21st Dec 2017, 8:59 PM
Aerial
Aerial - avatar
0
I love you xd
20th Dec 2017, 7:09 PM
Aerial
Aerial - avatar