I'm new at using manyconsole and I have a question about handling user output. I have method which multiplies two numbers. And I want to print my own error messages when, for example, I didn't enter all parameters. Now program, as far as I understand, shows default error messages. How can I change that? This is my command class
class MultCommand : ConsoleCommand
{
public int Argument1;
public int Argument2;
public int c;
public MultCommand()
{
IsCommand("mult","multiply numbers");
HasAdditionalArguments(2, "<Argument1> <Argument2>");
}
public override int Run(string[] remainingArguments)
{
if (remainingArguments == null || remainingArguments.Length == 0)
{
Console.WriteLine("You enter no numbers");
}
else
{
Argument1 = Convert.ToInt32(remainingArguments[0]);
Argument2 = Convert.ToInt32(remainingArguments[1]);
c = Argument1 * Argument2;
}
Console.WriteLine("Your answer is " + c.ToString());
return 0;
}
}
This is what I want You enter no numbers
This is what I get
Invalid number of arguments-- expected 2 more. 'mult' - multiply numbers Expected usage: Example.exe mult<Argument1> <Argument2>