CMD命令里怎么实现10秒倒数并显示10 9 8 7……

来源:百度知道 编辑:UC知道 时间:2024/06/04 11:36:28
CMD命令里怎么实现10秒倒数并显示10 9 8 7……

用C#
namespace ConsoleApp2
{
class Program
{
static System.Timers.Timer aTimer = new System.Timers.Timer();

static void Main(string[] args)
{
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = 1000;
aTimer.Enabled = true;
}

static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
aTimer.Stop();

for (int a = 10; a >0; a++)
{
Console.WriteLine(a);
}

aTimer.Start();
}
}
}

好像大概这样就可以了~
然后运行 生成 之后在CMD下运行就行了