- 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.
推薦閱讀
- Spring Cloud Alibaba微服務(wù)架構(gòu)設(shè)計與開發(fā)實戰(zhàn)
- C++ Builder 6.0下OpenGL編程技術(shù)
- 編寫高質(zhì)量代碼:改善C程序代碼的125個建議
- 名師講壇:Java微服務(wù)架構(gòu)實戰(zhàn)(SpringBoot+SpringCloud+Docker+RabbitMQ)
- CouchDB and PHP Web Development Beginner’s Guide
- Python機器學(xué)習(xí)實戰(zhàn)
- Flux Architecture
- 編程數(shù)學(xué)
- Instant Nancy Web Development
- Julia for Data Science
- Extreme C
- HTML5開發(fā)精要與實例詳解
- Django 3.0應(yīng)用開發(fā)詳解
- Mastering Machine Learning with R
- 計算思維與Python編程