问个简单问题,送送分

Tony_Xian Tony_Xian 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
每次循环a增加0.2,输出a的值,并输出hello,world,当a >= 10时,a的值一直保持为10,不增加,持续3秒,这段时间也输出hello,world,3秒过去a从10继续递增,下面代码应该怎样修改
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Threading;

namespace DataTest123
{
class Program
{
static void Main(string[] args)
{
bool delay = false;
double a = 0;
var sw = new Stopwatch();
while (true)
{
if(!delay)
a += 0.2;
Console.WriteLine(a);
if (a > 10)
{
sw.Start();
}
if (sw.ElapsedMilliseconds >= 3000)
{
delay = false;
sw.Stop();
sw.Reset();
}
Console.WriteLine("hello world");
}
}
}
}
...全文
评论 6
收藏 已收藏
分享
返回顶部
Tony_Xian
C# 111,128 成员 642,537 内容