Created
February 10, 2016 19:22
-
-
Save Fresh-Dev/5321bbf3283fcd7bb023 to your computer and use it in GitHub Desktop.
Random String Generator
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
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