I am making a program to analyse features of a user inputted sentence. To count the vowels in the sentence I have made a very messy sequence of foreach loops here:
foreach (char v1 in input)
{
if (v1 == 'a')
{
vcounter++;
}
}
foreach (char v2 in input)
{
if (v2 == 'e')
{
vcounter++;
}
}
foreach (char v3 in input)
{
if (v3 == 'i')
{
vcounter++;
}
}
foreach (char v4 in input)
{
if (v4 == 'o')
{
vcounter++;
}
}
foreach (char v5 in input)
{
if (v5 == 'u')
{
vcounter++;
}
}
I then take the vcounter and display it as the result. I am very new to c# and I am wondering if anyone can suggest a better way of doing this?.