3 ms·
In C#, the string object has some convenience in it: return inputString.Count( "eaoiuAIEOU".Contains ); Or if you want to solve two problems: static Rege
by logfromblammo 9y ago
In C#, the string object has some convenience in it:
return inputString.Count( "eaoiuAIEOU".Contains );
Or if you want to solve two problems:
static Regex VowelMatcher = new Regex( "[aeiou]",
RegexOptions.Compiled | RegexOptions.IgnoreCase );
...
return VowelMatcher.Matches( inputString ).Count;
And if you want to be clever and snarky:
return 2; // number of vowels in "a string"
- taco_emoji 9y agoThe Count and Contains methods are not on string, they're both extension methods on IEnumerable<T>, which string gets for free by implementing IEnumerable<char>.