View help typing help c#

Asked

Viewed 115 times

0

I need that when the user type help prints a help text, but this needs to work anywhere in the code and not in some parts. Same as CMD that when someone type help appears all available commands.

  • Could you edit your question and describe the step-by-step of how this is done?

  • I just edited:)

  • You have an application that runs on console and you want an explanatory text to appear when typing a command. This is it?

  • Yes, but the command can be typed at any time.

  • Someone to help me? It’s urgent :S

  • It is not clear yet. What is "any part of the code"? Where will the user type the command? That is, your console-running application already reads data entries for other things?

  • "any part of the code" means it can be typed at any time and within other data entries.

Show 2 more comments

1 answer

1


One option may be to define a method for ex:

public string LerEntradaConsole()
{
    string texto = Console.ReadLine();
    if (!texto.Contains("help"))
        return texto;
    else
    {
        ExibirTextoAjuda(texto);
        return LerEntradaConsole();
    }
}

And always use this method instead of Console.Readline(). In the Pagehelp method you will have to extract what the user typed and print the help on the screen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.