C generates a verification code that takes a random number plus the letter of

  • 2020-05-30 19:49:24
  • OfStack

Before 1 directly used to generate captcha method, take 4 digits no problem, the results plus letters, take 6 digits, the efficiency is very low.

Improved by 1. The method is as follows
 
var text2 = ""; 
var random = new Random((int)DateTime.Now.Ticks); 
const string textArray = "23456789ABCDEFGHGKLMNPQRSTUVWXYZ"; 
for (var i = 0; i < iVcodeNum; i++) 
{ 
text2 = text2 + textArray.Substring(random.Next() % textArray.Length, 1); 
} 
return text2; 

Related articles: