Thursday, 9 October 2014

random no generate method

 public static string CreatePassword()
        {
            int length = 8;
            string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
            string res = "";
            Random rnd = new Random();
            while (0 < length--)
                res += valid[rnd.Next(valid.Length)];
            return res;
        }

No comments:

Post a Comment