C#基础之显示当前时间

来源:互联网 发布:全国流动人口监测数据 编辑:程序博客网 时间:2024/05/29 17:27
using System;namespace datetime{    class Program    {        static void Main(string[] args)        {              Console.WriteLine("当前时间:{0}",DateTime.Now.ToString());   //(年/月/日 时:分:秒)              Console.WriteLine("当前时间:{0}", DateTime.Now);   //(年/月/日 时:分:秒)              Console.WriteLine("当前时间:{0}",DateTime.Now.ToShortTimeString());  //(时:分)              Console.WriteLine("当前时间:{0}",DateTime.Now.ToShortDateString());  //(年/月/日)              Console.WriteLine("当前时间:{0}",DateTime.Now.ToLongTimeString());  //(时:分:秒)              Console.WriteLine("当前时间:{0}", DateTime.Now.ToLongDateString());  //(年月 日)              Console.WriteLine("当前时间:{0}", DateTime.Now.ToLocalTime());  //(年/月/日 时:分:秒)              Console.WriteLine("当前时间:{0}", DateTime.Now.ToUniversalTime());            System.Threading.Thread.Sleep(6000);//当前线程休眠时间(既停留多久后继续后面操作)            Console.Clear();            //Console.ReadKey();        }    }}