Obviously, your bug is using
inputString.Contains
. It checks up is one string is a sub-string of another one, but your logic requires checking up is a single character is one of the vowels. Moreover, the calculation of the variable
vow
is completely pointless, and your call of
Contains
is just repeated
inputString.Length
times, giving the same result.
Instead, you should check up if you find
inputString[index]
in
vowels
. This is one of the simplest ways to do it:
http://msdn.microsoft.com/en-us/library/7eddebat.aspx[
^].
For example:
if (System.Array.IndexOf(vowels, inputString[index]) >= 0)
++vowelCount;
—SA