I have the a function I took from this post which works great:
private string GenerateTransactionCode()
{
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var result = new string(
Enumerable.Repeat(chars, 8)
.Select(s => s[random.Next(s.Length)])
.ToArray());
return result;
}
I would like to modify it so that instead of it being random, it picks the alpha numeric digits based on DateTime.UtcNow.Ticks
. This way it will be non-repeating. I suppose the characters in the resulting TransactionCode might need to be increased depending on the length of the milliseconds? I would like the length of the resulting TransactionCode to be constant. Hopefully, no more than 8 Characters.
Example: If the ticks happened to be 135
(going to me more than that in real life) then the resulting code will be ACE
or BDF
depending if it's 0 based (I don't care if it is or not).