18位流水号:
public static string GenerateTransId(int i)
{
string transId = DateTime.Now.ToString("yyyyMMddHHmmss");
int l = i - 14;
return transId + CreateRandCode(l);
}
public static string CreateRandCode(int codeLen)
{
string codeSerial = "1,2,3,4,5,6,7,a,c,d,e,f,h,i,j,k,m,n,p,r,s,t,A,C,D,E,F,G,H,J,K,M,N,P,Q,R,S,U,V,W,X,Y,Z";
if (codeLen == 0)
{
codeLen = 16;
}
string[] arr = codeSerial.Split(',');
string code = "";
int randValue = -1;
Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
for (int i = 0; i < codeLen; i++)
{
randValue = rand.Next(0, arr.Length - 1);
code += arr[randValue];
}
return code;
}