public static string RandomStr(int len) { string all = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; string[] allChar = all.Split(','); string result = ""; System.Random rand = new System.Random(); for (int i = 0; i < len; i++) { result += allChar[RandomExt.GenerateValue(0, allChar.Length)]; } return(result); }