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

  • Learn C# in 7 days
  • Gaurav Aroraa
  • 93字
  • 2021-07-08 09:51:28

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.

主站蜘蛛池模板: 安平县| 安溪县| 北碚区| 澄江县| 安仁县| 滨海县| 海原县| 吉林省| 宣城市| 凤翔县| 隆化县| 开平市| 同心县| 松原市| 伊通| 宁德市| 洱源县| 湾仔区| 繁昌县| 昌吉市| 方山县| 安泽县| 壶关县| 盈江县| 义马市| 永泰县| 三江| 新营市| 永寿县| 威远县| 怀集县| 郓城县| 达拉特旗| 安溪县| 外汇| 灵璧县| 山西省| 肇庆市| 福建省| 平泉县| 仙游县|