+ 1

How would one go about replacing all the vowels from the user input with a single character?

How would one go about replacing all the vowels from the user input with a single character? For example, a user input of: Hello world! Would be turned into: H*ll* w*rld

22nd Sep 2019, 12:32 AM
Goose
3 Antworten
0
This is what I came up with. I didn't do the user input part and i only did it for lowercase vowels but it should be easy enough to add that. 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) { char newchar = '*'; char[] vowels = {'a','e','i','o','u'}; string phrase = "Hello world!"; Console.WriteLine(phrase); for (int x=0;x<phrase.Length; x++) { for(int y=0;y<vowels.Length; y++) { if (phrase[x] == vowels[y]) { phrase = phrase.Replace(phrase[x], newchar); } } } Console.WriteLine(phrase); } } }
22nd Sep 2019, 1:36 AM
Bill
Bill - avatar
0
in what language?
22nd Sep 2019, 12:38 AM
Bill
Bill - avatar
0
C#
22nd Sep 2019, 12:39 AM
Goose