Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 程序在运行中结束_C#_Console.writeline - Fatal编程技术网

C# 程序在运行中结束

C# 程序在运行中结束,c#,console.writeline,C#,Console.writeline,我的代码正在启动,然后当我去输入我想要尝试点击的区域时,它移动到第48行,在那里它开始打印“你试图点击”中的“+enemyUsing+”等等 但它会因为某种原因而结束!请帮忙 只需删除break位于第150行,退出while(i==1)循环 另外,看起来您将else块放错了位置,应该是在检查用户输入之后,而不是在if(playerHealth==0) 断点的位置实际上应该在您的退出条件之一之后 else { Console.WriteLine("That is not one

我的代码正在启动,然后当我去输入我想要尝试点击的区域时,它移动到第48行,在那里它开始打印“你试图点击”中的“+enemyUsing+”等等
但它会因为某种原因而结束!请帮忙

只需删除
break位于第150行,退出
while(i==1)
循环

另外,看起来您将
else
块放错了位置,应该是在检查用户输入之后,而不是在
if(playerHealth==0)

断点的位置实际上应该在您的退出条件之一之后

else
{
    Console.WriteLine("That is not one of the available limbs, please select one of the following:\nHead\nTorso\nArms\nLegs");
}

你能详细说明一下你面临的问题吗。我在本地运行了相同的代码,看起来还可以。谢谢!成功了:)
else
{
    Console.WriteLine("That is not one of the available limbs, please select one of the following:\nHead\nTorso\nArms\nLegs");
}
else
{
    Console.WriteLine("You have shredded the enemy\nPress any key to exit");
}

Console.ReadKey();
break; // exit while loop or return; if you want to stop game