【发布时间】:2021-07-06 12:23:23
【问题描述】:
这是一个简单的计时器,从用户设置的值开始倒计时到 0
namespace SuperSimpleTimer
{
class Program
{
static void Main(string[] args)
{
//This makes the loop starts from a user inserted value
myTime = int.Parse(Console.ReadLine());
for (int i = myTime; i >= 0; i--)
{
// clears the old value and Writes the new one
//Console.Clear();
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}
【问题讨论】:
-
System.Threading.Thread.Sleep(1000);延迟 1 秒 - 但我认为这不是你真正想要发生的事情 -
这能回答你的问题吗? Time delay in For loop in c#