圖片生成與隨機數生成函數
1 /// <summary>
2 /// 生成隨機碼
3 /// </summary>
4 /// <param name="length">隨機碼個數</param>
5 /// <returns></returns>
6 private string CreateRandomCode(int length)
7 {
8 int rand;
9 char code;
10 string randomcode = String.Empty;
11
12 //生成一定長度的驗證碼
13 System.Random random = new Random();
14 for (int i = 0; i < length; i++)
15 {
16 rand = random.Next();
17
18 if (rand % 3 == 0)
19 {
20 code = (char)(A + (char)(rand % 26));
21 }