我如何做到这一点,所以在该程序结束时,它要求另一个输入,以便重置表单并根据新输入创建另一个表单?
static void Main()
{
String totalsecondsstring;
int totalseconds, hour, minutes, second;
Console.WriteLine("How long did the race take (in seconds)?");
totalsecondsstring = Console.ReadLine();
totalseconds = Convert.ToInt32(totalsecondsstring);
hour = totalseconds / 3600;
minutes = (totalseconds - (hour * 3600)) / 60;
second = (totalseconds - (hour * 3600)) - (minutes * 60);
Console.Write("Runers Time\n");
Console.WriteLine("-----------\n");
Console.WriteLine("{0,-5} | {1,-5} | {2,-5} | {3,-5}", "Runner ", hour + " hours", minutes + " minutes", second + " seconds");
}
最佳答案
两个建议:
使用while(true)
循环:
static void Main(string[] args) {
while(true) {
// Your code
}
}
在
Main
方法的末尾调用Main
方法:static void Main(string[] args) {
// Your code
Main();
}
我建议您使用第一种方法。