-1

So, I am making a hacking game, and in it you control a terminal. So far, I have done 'help' and 'cls' commands, that don't require parameters. But, for say a echo command, I need the computer to detect the keyword 'echo' and the rest of the text as what you want to 'echo'. How can I do this? Thanks for any help.

  • Does [link](http://stackoverflow.com/questions/10319531/is-there-an-equivalent-of-echo-in-asp-net-c-sharp) answer your question? – AMACB Oct 29 '15 at 02:48

1 Answers1

1

You can do something line this:

var input = Console.ReadLine(); //You might have this already in your code

if (input.StartsWith("echo "))
{
    var text = input.Substring(5);

    Console.WriteLine(text);
}

This checks to see if the input line starts with echo, and if it does, it prints to the console whatever is after the first 5 characters (which is the length of echo and one space)

Yacoub Massad
  • 27,509
  • 2
  • 36
  • 62