I would like to generate unique alphanumeric max 50 character string based on a client ID. What is the chance of getting the same string by the way? I have more than one client, I don't want strings to be overlapped.
Here is what I planning to use:
static Random _Random = new Random();
static char[] _AllowedChars =
Enumerable.Range(48, 10).Select(x => (char)x)
.Concat(Enumerable.Range(65, 26).Select(x => (char)x))
.Concat(Enumerable.Range(97, 26).Select(x => (char)x))
.ToArray();
static string PseudoUniqueString(int maxLength = 50)
=> new string(Enumerable.Range(1, Math.Max(1, maxLength))
.Select(x => _AllowedChars[_Random.Next(_AllowedChars.Length)])
.ToArray());
Is there a way to add client ID (let's say 1) at the beginning of this string? I don't come up with another solution. Advice needed.
edit: This string will be used as a transaction number in a web API and there will be more than 1 client. Thats why I am thinking of adding client ID into this string.