我无法弄清楚要放在括号中的内容,以便我的程序检查输入是否为数字.如果没有,我想返回错误,然后重新启动进程.有什么建议?
bool running = true;
Console.Write("Enter the number of victims so we can predict the next murder, Sherlock: ");
while (running)
{
victimCount = int.Parse(Console.ReadLine());
if (/*I want victimCount only to be accepted if it's a number*/)
{
Console.Write("\nThat's an invalid entry. Enter a correct number!: ");
}
else
{
running = false;
}
}
Run Code Online (Sandbox Code Playgroud)