I. C # statement Overview (this part comes from the Network)
Statement (statement ):Program activities are expressed by statements. C # supports multiple different statements. Many statements are defined in the form of embedded statements.
Block ):You can write multiple statements in the context where only one statement can be used. A block consists of a list of statements enclosed in braces.
Statement (declaration statement ):Declare local variables and constants.
Expression statement ):Expressions include method calls, object allocation using the new operator, and assignment using the "=" and compound assignment operators, and the increment and decrement operations using the "++" and "--" operators.
Selection statement ):Used to select one of several possible statements based on the value of an expression.
If else statement
Switch statement
Iteration statement ):Used to execute embedded statements repeatedly
While statement
Do While statement
For statement
Foreach statement.
Jump statement (jump statement ):It is used for transfer program control.
Break statement
Continue statement
Goto statement
Throw statement
Return Statement
Exception Handling statement(Try-catch-finally ):Used to capture exceptions that occur during block execution.
Try-catch statement
Try-finally statement
Try-catch-finally statement
The try-[catch]-finally statement is used to specify a termination code block. whether an exception occurs or not, it is always executed.
Ii. checked and unchecked statements: used to control integer arithmetic operations and overflow checks for conversions.
Checked checks possible violations in the domain to which it applies and throws an exception. unchecked blocks all checks.
For example: