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

  • 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.

主站蜘蛛池模板: 三门峡市| 本溪市| 阳高县| 紫金县| 陇西县| 大埔区| 和田市| 鄄城县| 诏安县| 浙江省| 大城县| 海安县| 德兴市| 海林市| 东港市| 临潭县| 马龙县| 辉县市| 连山| 修文县| 合肥市| 通州区| 渭源县| 余干县| 朔州市| 永川市| 瑞昌市| 长武县| 乌拉特后旗| 牡丹江市| 桂林市| 丹东市| 卢氏县| 河源市| 外汇| 凤凰县| 平罗县| 英山县| 沙雅县| 时尚| 兴和县|