public static string GetRandomCode( int codeLength) |
{ |
char [] codes = { '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'J' , 'K' , 'L' , 'M' , 'N' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' }; |
string res= "" ; |
Random rd = new Random(); |
try |
{ |
for ( int i = 0; i < 4; i++) |
{ |
res+=(codes[rd.Next(0, codes.Length)]); |
} |
} |
catch (Exception ex) |
{ |
res=( "fail" + ex.Message + ex.StackTrace); |
} |
return res; |
} |