由于某种原因,C#程序一运行就会卡住(空白命令行)
我编写了一个简单的C#程序,由于某种原因无法打印main中的第一行。 同一解决方案中的所有其他4个项目都可以顺利运行。 如果我提到解决方案中的一个项目正在该项目中被引用,而该项目没有运行,这可能会有所帮助 代码如下:由于某种原因,C#程序一运行就会卡住(空白命令行),c#,loops,cmd,C#,Loops,Cmd,我编写了一个简单的C#程序,由于某种原因无法打印main中的第一行。 同一解决方案中的所有其他4个项目都可以顺利运行。 如果我提到解决方案中的一个项目正在该项目中被引用,而该项目没有运行,这可能会有所帮助 代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Basic_Sand_Clock;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Basic_Sand_Clock;
namespace Advanced_Sand_Clock
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("sdsd");
// string advancedSandClock = GenerateAdvancedSandClock(9);
// Console.WriteLine(advancedSandClock);
// Console.ReadLine();
}
private static uint GetValidInput()
{
string stringInput = "";
uint sandClockHeight = 0;
while (stringInput.Equals(""))
{
stringInput = Console.ReadLine();
if (!uint.TryParse(stringInput, out sandClockHeight))
{
Console.WriteLine("Please enter a positive number");
stringInput = "";
}
}
return sandClockHeight;
}
private static string GenerateAdvancedSandClock(uint height)
{
if (height % 2 == 0)
{
height++;
}
StringBuilder stringBuilder = new StringBuilder();
StringBuilder sandClock = Basic_Sand_Clock.Program.GenerateSandClockWithInput(stringBuilder, height);
return sandClock.ToString();
}
}
}
我得到的是:
解决方案资源管理器的另一个屏幕截图:
当您逐行调试时,您发现…?您是否已尝试等待几秒钟?调试器可能需要一些时间来附加,以确保在项目属性中,您的属性按预期指向
Program.Main
方法。是否将此项目设置为启动项目并选择了正确的对象?您是否尝试在预期的第一行上设置断点?请拍摄此解决方案的解决方案资源管理器的屏幕截图,并向我们展示。