(很抱歉,如果某些部分不正确...
我对C#语法有点新手)
我目前正在从事命令行项目。该项目涉及创建一个解决欧拉项目4问题的算法:
https://projecteuler.net/problem=4
从一开始,从开始挑战开始,我就一直使用Visual Studio来解决它们。我一直在使用“C#命令行”类型的项目来解释信息。
自从我开始使用这种类型的Windows窗体以来,我已经发现:
static void Main(string[] args)
{
//Insert Code Here...
}
函数完成其事件和参数,突然崩溃(很好,关闭)
我相信这是因为它拥有并结束,它本身就结束了...
我可能是错的...
同时,我只是使用Thread.Sleep()函数作为临时修复程序。
我该如何解决这个问题,为什么您会这样呢?
谢谢!
最佳答案
尝试这个:
public static void Main(string[] args)
{
try
{
// Your code here
}
catch (Exception ex)
{
// This code will only run if your code fails
Console.WriteLine(ex.ToString()); // Show the exception on the console.
}
Console.ReadKey(); // Make a pause so that the screen does not dissapears when I hit Debug -> Run
}
关于c# - C#命令行脚本在Visual Studio中过早结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38624660/