- 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.
推薦閱讀
- INSTANT Mock Testing with PowerMock
- Node.js+Webpack開發實戰
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- 3D少兒游戲編程(原書第2版)
- The Complete Coding Interview Guide in Java
- Java EE 7 Performance Tuning and Optimization
- Extending Puppet(Second Edition)
- 從零開始學Linux編程
- Getting Started with Polymer
- Kotlin進階實戰
- Hands-On Dependency Injection in Go
- Implementing Microsoft Dynamics NAV(Third Edition)
- Mastering Drupal 8
- C Primer Plus(第6版)中文版【最新修訂版】
- 網絡綜合布線與組網實戰指南