pig latin Code gets skipped? C#
I programmed a code for the pig latin puzzle but the while loop gets skipped(?) and it just outputs the original sentence... Here's the code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string sentence = Console.ReadLine(); int i = 0; char letter; sentence += " "; while(i <= sentence.Length) { letter = sentence[i]; sentence.Remove(i, 1); while(sentence[i] != ' ') { i++; } sentence.Insert(i, letter + "ay"); i += 4; } Console.Write(sentence); } } }