官术网_书友最值得收藏!

The if..else statement

In this if statement followed by else and the else block execute in case evaluation of if block is false. This is a simple example:

private static void IfElseStatementExample() 
{ 
WriteLine("if statement example."); 
Write("Enter character:"); 
char inputChar = Convert.ToChar(ReadLine()); 
char[] vowels = {'a', 'e', 'i', 'o', 'u'}; 
 
if (vowels.Contains(char.ToLower(inputChar))) 
WriteLine($"Character '{inputChar}' is a vowel."); 
else 
WriteLine($"Character '{inputChar}' is a consonent."); 
} 

In the preceding code snippet, we are using else followed by the if statement. When the if statement evaluates to false, then the else block code will be executed.

主站蜘蛛池模板: 达日县| 日照市| 哈密市| 上思县| 焦作市| 莎车县| 长乐市| 林州市| 邹城市| 仙桃市| 五华县| 钟山县| 西林县| 玉林市| 新民市| 察雅县| 牟定县| 博湖县| 贵南县| 卓尼县| 云南省| 田阳县| 龙岩市| 龙岩市| 平利县| 新宁县| 大庆市| 韩城市| 长寿区| 芜湖市| 南康市| 湾仔区| 黄梅县| 玛纳斯县| 防城港市| 陈巴尔虎旗| 托克托县| 天津市| 怀宁县| 昭觉县| 靖远县|