+ 3
If or switch?
Is there any situation in which It'd be better to choose if instead of switch?
3 Answers
+ 4
Mina is right. For just a few items, the difference is small. But if you have many items you should definitely use a switch - switch have better performances.
http://www.dotnetperls.com/if-switch-performance
+ 5
If you have 1 or 2 options it's maybe better (and more common) to use if statement but it's your choice.
+ 2
And I forget one important thing: 99,999% of the time you shouldn't care about performances if vs. switch. :)