DateTime.Now.ToString("yyyyMMddHHmmss");

 public static string geneTransId(string iStr)
        {
            return iStr + "." + DateTime.Now.ToString("yyyyMMddHHmmss");
        }

        public static string geneReticleTransId(string iStr)
        {
            return iStr + "." + DateTime.Now.ToString("ddHHmmss");
        }

        static void Main(string[] args)
        {
            Console.WriteLine(geneTransId("geneTransId"));
            Console.WriteLine(geneReticleTransId("geneReticleTransId"));
            // geneTransId.20160503131710
            //geneReticleTransId.03131710
            //请按任意键继续. . .
        }

你可能感兴趣的:(.NET,C#)