C#编程制作时间显示器源代码 c#时间控件怎么用

C#编程制作时间显示器源代码 c#时间控件怎么用

编码文章call10242024-12-22 14:42:3122A+A-

基于视频讲解的时间显示器源代码,理解控制台、线程类和无限for循环语句的使用:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.Title = "时间显示";//控制台应用程序窗口标题设置
            System.Console.WindowWidth = 70;//控制台应用程序窗口宽度设置
            System.Console.WindowHeight = 10;//控制台应用程序窗口高度设置
            for(;;)
            {
                //按相应的格式输出系统时间(年/月/日 时:分:秒)
                System.Console.WriteLine("当前时间是:\n{0}",System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"));
                System.Threading.Thread.Sleep(1000);//每隔1000ms(1秒钟)刷新时间
                System.Console.Clear();//清空显示内容来重新显示时间
            }
        }
    }
}

结语:喜欢的请关注,收藏和转发!

点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4