The first if
statement in this program checks a string against a letter I am using the logical or
operator (||
) to compare the first letter against the string. It's tedious and for the future I am looking for a way to this faster and make it shorter.
string strUser;
string strSubCheck;
Console.WriteLine("Please type in a word:");
strUser = Console.ReadLine();
strSubCheck = strUser.Substring(0, 1);
if(strSubCheck == "A" || strSubCheck == "a" || strSubCheck == "E" || strSubCheck == "e" || strSubCheck == "I" || strSubCheck == "i" || strSubCheck == "O" || strSubCheck == "o" || strSubCheck == "U" || strSubCheck == "u")
{
Console.WriteLine("\nThe first letter is a vowel");
}
else Console.WriteLine("\nThe first letter is a consonant");