- 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.
推薦閱讀
- HornetQ Messaging Developer’s Guide
- Mastering Entity Framework Core 2.0
- Modular Programming with Python
- Progressive Web Apps with React
- JIRA 7 Administration Cookbook(Second Edition)
- 區塊鏈:以太坊DApp開發實戰
- Python GUI Programming Cookbook
- Python Network Programming Cookbook(Second Edition)
- MySQL數據庫基礎實例教程(微課版)
- Python Data Structures and Algorithms
- Lighttpd源碼分析
- Regression Analysis with Python
- Drupal Search Engine Optimization
- 計算機應用基礎案例教程(第二版)
- 游戲設計的底層邏輯