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

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.

主站蜘蛛池模板: 应城市| 佛冈县| 海兴县| 祁阳县| 上犹县| 县级市| 图们市| 望江县| 高淳县| 甘孜县| 南召县| 溧水县| 镇坪县| 黄石市| 永定县| 绥德县| 松滋市| 石首市| 襄汾县| 中西区| 辽阳市| 盐山县| 侯马市| 钟山县| 新乡县| 印江| 若尔盖县| 兰州市| 达孜县| 囊谦县| 施甸县| 镶黄旗| 阿瓦提县| 水城县| 海盐县| 黔江区| 潮安县| 林西县| 宝坻区| 三河市| 武宣县|