Created
July 10, 2021 08:31
-
-
Save Harry260/7c25e78b62a3f948c5dc3ea06af1144b to your computer and use it in GitHub Desktop.
Generate random alphanumerals with c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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