What is the difference between if-else if statement and switch statement? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

What is the difference between if-else if statement and switch statement?

C#

14th Apr 2020, 7:41 PM
Mohamed Waseem
Mohamed Waseem - avatar
2 Respuestas
+ 7
The fundamental difference between if-else and switch statement is that the  if-else statement. selects the execution of the statements based upon the evaluation of the expression in if statements”. The switch statements “selects the execution of the statement often according to a keyboard command
14th Apr 2020, 8:11 PM
SHADOW 🌀
SHADOW 🌀 - avatar
+ 1
Mohamed Waseem Main difference is that you use switch when you have constant values. When using if-statements, you can ask for more specific conditions like: <, >, etc.
14th Apr 2020, 8:25 PM
CapCode