public static string GenerateCaptchaCode(int len) { char[] data = {‘a‘,‘c‘,‘d‘,‘e‘,‘f‘,‘g‘,‘k‘,‘m‘,‘p‘,‘r‘,‘s‘,‘t‘,‘w‘,‘x‘,‘y‘,‘3‘,‘4‘,‘5‘,‘7‘,‘8‘ }; StringBuilder sbCode = new StringBuilder(); Random rand = new Random(); for(int i=0;i<len;i++) { char ch = data[rand.Next(data.Length)]; sbCode.Append(ch); } return sbCode.ToString(); }