Skip to content

Instantly share code, notes, and snippets.

@nohe427
Created January 21, 2015 21:50
Show Gist options
  • Save nohe427/2d82ddfa9793822d8af2 to your computer and use it in GitHub Desktop.
Save nohe427/2d82ddfa9793822d8af2 to your computer and use it in GitHub Desktop.
void Button1Click(object sender, EventArgs e)
{
string name;
name = textBox1.Text;
string pigName = "";
makePigLatin(ref pigName, name);
label1.Text = pigName;
}
public void makePigLatin(ref string pigName, string name)
{
string vowels = "AEIOUaeiou";
string firstLetter;
string restOfWord;
int letterPos;
firstLetter = name.Substring(0, 1);
restOfWord = name.Substring(1, name.Length - 1);
letterPos = vowels.IndexOf(firstLetter);
if (letterPos == -1)
pigName = restOfWord + firstLetter + "ay";
else
pigName = name + "way";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment