Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Form1_Load(object sender, EventArgs e)
- {
- string ToPigLatin(string sentence)
- {
- const string vowels = "AEIOUaeio";
- List<string> pigWords = new List<string>();
- foreach (string word in sentence.Split(' '))
- {
- string firstLetter = word.Substring(0, 1);
- string restOfWord = word.Substring(1, word.Length - 1);
- int currentLetter = vowels.IndexOf(firstLetter);
- if (currentLetter == -1)
- {
- pigWords.Add(restOfWord + firstLetter + "ay");
- }
- else
- {
- pigWords.Add(word + "way");
- }
- }
- return string.Join(" ", pigWords);
- }
- Console.WriteLine(ToPigLatin("this is a test sentence to see if pig latin actually works and what will become of this"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement