Skip to content

Instantly share code, notes, and snippets.

@gvoysey
Created August 31, 2015 15:19
Show Gist options
  • Select an option

  • Save gvoysey/5f52d3a0c20632c65484 to your computer and use it in GitHub Desktop.

Select an option

Save gvoysey/5f52d3a0c20632c65484 to your computer and use it in GitHub Desktop.
A generator for fake names
public class FakeNameGenerator
{
private static readonly Random Random = new Random();
private static readonly List<string> _vowels = new List<string> {"a", "e", "i", "o", "u"};
private static readonly List<string> _consonants = new List<string>
{
"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q",
"r", "s", "t", "v", "w", "x", "y", "z"
};
private static string Vowel()
{
return _vowels[Random.Next(_vowels.Count)];
}
private static string Consonant()
{
return _consonants[Random.Next(_consonants.Count)];
}
private static string Cv()
{
return Consonant() + Vowel();
}
private static string Cvc()
{
return Cv() + Consonant();
}
private static string Syllable()
{
return Vowel() + Cv() + Cvc();
}
public static string FakeName()
{
var word = "";
var syllables = Random.Next(2, 3);
for (int i = 0; i < syllables; i++)
{
word += Syllable();
}
word = char.ToUpper(word[0])+word.Substring(1);
return word;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment