Skip to content

Instantly share code, notes, and snippets.

@Fresh-Dev
Created February 10, 2016 19:22
Show Gist options
  • Save Fresh-Dev/5321bbf3283fcd7bb023 to your computer and use it in GitHub Desktop.
Save Fresh-Dev/5321bbf3283fcd7bb023 to your computer and use it in GitHub Desktop.
Random String Generator
private static Random _rnd = new Random();
public static string Generate(string pattern)
{
string text = string.Empty;
string[] array = new string[]{"a","e","i","o","u"};
string[] array2 = new string[]{"b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"};
string[] array3 = new string[]{"0","1","2","3","4","5","6","7","8","9"};
char[] p = pattern.ToCharArray();
for (int i = 0; i < p.Length; i++){if (p[i] == 'c'){text += array2[_rnd.Next(array2.Length)];}if (p[i] == 'v'){text += array[_rnd.Next(array.Length)];}if (p[i] == 'n'){text += array3[_rnd.Next(array3.Length)];}}
return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment