Skip to content

Instantly share code, notes, and snippets.

@Harry260
Created July 10, 2021 08:31
Show Gist options
  • Select an option

  • Save Harry260/7c25e78b62a3f948c5dc3ea06af1144b to your computer and use it in GitHub Desktop.

Select an option

Save Harry260/7c25e78b62a3f948c5dc3ea06af1144b to your computer and use it in GitHub Desktop.
Generate random alphanumerals with c#
public string randomID(int length = 5)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var randomString = new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
return randomString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment