Study Notes (36): C # fast entry -switch-case statement

Learning immediately: https://edu.csdn.net/course/play/20589/257741?utm_source=blogtoedu

1. switch-case syntax structure

switch(表达式/变量)
{
    case 值1:
        语句块1;
        break;           //break 表示跳出switch语句
    case 值2:
        语句块2;
        break;
    default:
        语句块3;
        break;
}

 2. switch-case and if-elseif similarities and differences:

The same point: the branch structure can be achieved

difference:

(1) if-elseif: range may process (bool value)

(2) switch: generally only for equivalence comparison

Published 34 original articles · won praise 0 · Views 311

Guess you like

Origin blog.csdn.net/u013162262/article/details/104861921