c#日期与字符格式互转(用于流水号)

 class Program
    {
        static void Main(string[] args)
        {
           //将日期格式转为字符输出
           string a = "CL" + DateTime.Now.ToString("yyyyMMddHHmmssms");
           Console.WriteLine(a);
            //将字符格式转为字符输出
           DateTime dt = DateTime.ParseExact("201910090914351435", "yyyyMMddHHmmssms", System.Globalization.CultureInfo.CurrentCulture);
           Console.WriteLine(dt);
           Console.ReadKey();
        }
    }

 

 

posted @ 2019-10-09 09:20  风葬秋暝  阅读(387)  评论(0编辑  收藏  举报