Last active
December 18, 2015 16:52
-
-
Save ZackStone/85ad617110d085c8f2f4 to your computer and use it in GitHub Desktop.
Random true flag
This file contains 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
[Flags] | |
public enum CharType | |
{ | |
Number = 0x0, | |
Upper = 0x1, | |
Lower = 0x2 | |
} | |
public CharGenerator(CharType charType) | |
{ | |
this. _random = new Random(); | |
} | |
public char genarateRandomChar(CharType charType) | |
{ | |
string temp = string.Empty; | |
// I want to modify this. | |
if (charType.HasFlag(CharType.Number)) | |
{ | |
temp += this.gerarCharNumber(); // call #1 | |
} | |
if (charType.HasFlag(CharType.Upper)) | |
{ | |
temp += this.gerarCharUpper(); // call #2 | |
} | |
if (charType.HasFlag(CharType.Lower)) | |
{ | |
temp += this.gerarCharLower(); // call #3 | |
} | |
// I call 3 methods to use only one char. | |
return temp[_random.Next(0, temp.Length)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment