C# Count Vowels

后端 未结 17 1716
小鲜肉
小鲜肉 2020-12-03 08:59

I am learning to program C# and I am trying to count the vowels. I am getting the program to loop through the sentence, but instead of returning vowel count, it is just retu

17条回答
  •  抹茶落季
    2020-12-03 09:34

    int cnt = 0;
    for (char c in sentence.ToLower())
        if ("aeiou".Contains(c))
           cnt++;
    return cnt;
    

提交回复
热议问题