Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private string ID()
- {
- string uniqueId = string.Empty;
- string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+"; // All Alphabet Characters
- int idSize = 10; // Size Of Unique ID
- int a_OR_0; //Determine if Char will be numeric or alphabetical
- for (int i = 0; i < idSize; i++)
- {
- a_OR_0 = Random.Range(0, 2);
- switch (a_OR_0)
- {
- case 0: // letter
- {
- uniqueId += alphabet[Random.Range(0, alphabet.Length)];
- break;
- }
- case 1: // number
- {
- uniqueId += Random.Range(0, 9).ToString();
- break;
- }
- //The Random Function Seemed to prefer alphabetical so a second chance of numeric seems to balance this
- default: //number
- {
- uniqueId += Random.Range(0, 9).ToString();
- break;
- }
- }
- }
- return uniqueId;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement