Code
1 private string getRanString(int StrLength)
2 {
3 Random ran = new Random();
4 string str = "";
5 int i = 0;
6 do
7 {
8 int num = (int)(ran.NextDouble() * 122);
9 if (num > 47)
10 {
11 if (!(((num > 57) & (num < 65)) | ((num > 90) & (num < 97))))
12 {
13 str = str + Convert.ToChar(num);
14 i++;
15 }
16 }
17 }
18 while (i < StrLength);
19 return str;
20 }
21
22 static string GetCode(int num)
23 {
24 string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
25 StringBuilder sb = new StringBuilder();
26 for(int i = 0; i < num; i++)
27 {
28 sb.Append(a[new Random(Guid.NewGuid().GetHashCode()).Next(0, a.Length -1)]);
29 }
30
31 return sb.ToString();
32 }