What must be the expression after case in the switch statement?
Jul 12, 2021 pm 01:47 PMThe expression after the case label must be a constant expression, such as "42" or "'4'". At the same time, it must be a unique expression, that is, two cases are not allowed to have the same value.
The operating environment of this tutorial: Windows 7 system, Dell G3 computer.
The case tag (after case) must be a constant expression (constantExpression), such as 42 or '4'.
The case tag (after case) must be a unique expression; that is, two cases are not allowed to have the same value.
Other rules:
Switch can only be used for integer types in basic data types, including int, char, etc. For other types, you must use an if statement.
The parameter type of switch() cannot be real type.
Extended information:
Related extension: The syntax of the switch statement is as follows (switch, case, break and default are keywords) :
switch ( 变量表达式 ) { case 常量1 :语句;break; case 常量2 :语句;break; case 常量3 :语句;break; ... case 常量n:语句;break; default :语句;break; }
For more computer-related knowledge, please visit the FAQ column!
The above is the detailed content of What must be the expression after case in the switch statement?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What are the differences between the Japanese and Hong Kong versions of switch?

What should I do if the switch does not respond to the TV?

Can the switch be charged on the base all the time?

Can Elden's Ring be played on switch?

What is the difference between switch lite and switch

Is the default option required in the switch statement?

It is reported that Sega has a Nintendo Switch 2 development kit, and 'FF7: R' looks like a PS5 game when running on the Switch 2