Thursday, 9 October 2014

Generate Date Time as a random no.

            int n1, s1 = 0;
            int z1 = 2;
            string m1 = "";
            string reverse1 = "";

            string i1 = System.DateTime.Now.ToShortDateString();               \\Current  Date
            string j1 = System.DateTime.Now.ToLongTimeString();                \\Current Time
            string[] a1 = i1.Split('-');
            int k1 = Convert.ToInt32(a1[0]);
            while (z1 != 0)
            {
                n1 = k1 % 10;
                m1 += (s1 * 10 + n1).ToString();
                k1 = k1 / 10;
                z1 = z1 - 1;
            }

            for (int eb = m1.Length - 1; eb > -1; eb--)                               \\ Find last 2 digit of the year
            {
                reverse1 += m1[eb];
            }
            string[] b1 = j1.Split(' ');
            string x01 = b1[0];
            string[] c01 = x01.Split(':');
            string ran = reverse1 + a1[1] + a1[2] + c01[0] + c01[1];
            string bno = "R" + ran;                                         \\ Add "R" in starting of the random no                                      

No comments:

Post a Comment