I need to count all the vowels and replace it with the letter x in the text box. I managed to make the counting part, and here is the code, but I have a problem with replacing all the vowels in the text box with the letter x. Can anybody help me?
int total = 0;
string sentence = textBox1.Text.ToLower();
char[] vowels = { 'a', 'e', 'i', 'o', 'u', 'y'};
{
total++;
}
total = sentence.Count(c => vowels.Contains(c));
MessageBox.Show("There are " + total++ " vowels";
for (int i = 0; i < sentence.Length; i++)
EDIT 1 :
Thank you all for your help. For some reason, the vowels in my text box do not change !!! It does the counting, but does not replace the letter x. I tried all the solutions here, but so far nothing has happened with my vowels in the text box.
source
share