Do else if statements exist in C#?

前端 未结 8 1571
感动是毒
感动是毒 2021-02-01 12:51

I have come across the following code in C#.

if(condition0) statement0;
else if(condition1) statement1;
else if(condition2) statement2;
else if(condition3) state         


        
8条回答
  •  被撕碎了的回忆
    2021-02-01 13:30

    The two examples you give are equivalent in every language. In C or C#, it's exactly equivalent to an else, then if. In some other languages, elseif is syntactic sugar for else, then if. So no matter which language you use, they will compile to the same code (or be interpreted to the same behavior). See http://en.wikipedia.org/wiki/Conditional_%28programming%29#Else_If

提交回复
热议问题