C#验证码的另一种操作方法

时间:2022-06-20 15:49:18
  sb = new StringBuilder();
char c = '0';
string s = "";
for (int i = 0; i < 4; i++)
{
Random r = new Random(); int a = r.Next(97, 122);           //因为计算机处理速度很快,需要强制让线程睡一会, 不然结果会一样
System.Threading.Thread.Sleep(100);
c = (char)a;
sb.Append(c); } label4.ForeColor = Color.DarkRed; label4.Text = sb.ToString();