gpt4 book ai didi

c# - 在 C# 中循环表单

转载 作者:太空宇宙 更新时间:2023-11-03 23:42:52 24 4
gpt4 key购买 nike

如何在程序结束时请求另一个输入,以便重置表单并根据新输入制作另一个表单?

 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();
}

我建议你使用第一种方法。

关于c# - 在 C# 中循环表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28461307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com