Skip to content

Instantly share code, notes, and snippets.

@ZackStone
Last active December 18, 2015 16:52
Show Gist options
  • Save ZackStone/85ad617110d085c8f2f4 to your computer and use it in GitHub Desktop.
Save ZackStone/85ad617110d085c8f2f4 to your computer and use it in GitHub Desktop.
Random true flag
[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