Hi Guys,
when we use if/else and when Switch?
Give an example of if/else which is not possible with Switch and vice versa.
Thanks.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted May 31, 2013, 9:58 PM EDT
Types(Day,Month,Year, Category,Gender,CommandName,Action,Age)
same thing you can also do in if/else statments like if else ladger
But when we have candition that depends on multple parameter then need to use if/else, cann't use swicth,
like--- CommandName and CommandArguments
Type and Flag
mursaleen fayyaz83 reputationPosted May 31, 2013, 10:37 PM EDT
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted May 31, 2013, 11:10 PM EDT
Ravi ShekharRank #673 · 3.6K reputationPosted Jun 1, 2013, 1:20 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 1, 2013, 2:48 AM EDT
If you have a variable type other than these, then you have to use an if/else ladder even if there's only a single variable involved.