Is there any significant difference between using if/else and switch-case in C#?

What is the benefit/downside to using a switch statement vs. an if/else in C#. I can’t imagine there being that big of a difference, other than maybe the look of your code.

Is there any reason why the resulting IL or associated runtime performance would be radically different?

Related: What is quicker, switch on string or elseif on type?

20 Answers
20

Leave a Comment