Hi, What is the difference between “if” and “switch” in C# ?

Updated on July 26, 2018 in [A] C# .Net
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on July 20, 2018

Hi everybody! I have a question. What is the difference between “if” and “switch”?

Thanks

  • Liked by
Reply
0 on July 25, 2018

Try to google it but generally both are the same.

  • Liked by
Reply
Cancel
0 on July 26, 2018

It’s also worth noting that if statements are more efficient, but if you have 3 or more else-ifs in your code, you’re really probably just better off (organizationally) using a switch statement, unless it’s in a largely repeating for loop where the efficiency would be an issue.

  • Liked by
Reply
Cancel