1 goto statement
C # allows you to tag lines of code so that you can jump directly to them using a goto statement. The advantages and disadvantages of this statement coexist. The main thing is this: this is an easy way to control when to execute what code. The main drawback is that excessive use of this technique will make the code difficult to understand.
Goto <labelName>
23-tuple operator
<test>?<resultIfTrue>:<resultIfFalse>
Where calculation <test> can get a Boolean value, the result of the operation is determined by this value is <resultIfTrue> or <resultIfFalse>.
3 If statement
If statement has more functions, it is an effective decision-making way. Unlike the?: statement, the IF statement has no result (so it is not used in an assignment statement), and the statement is used for conditional execution of other statements.
4 Switch statements
The switch statement is very similar to the IF statement because he is also conditionally executing code based on the value of the test, but the switch statement can compare the test variable to more than one value at a time, instead of just testing a condition. This test is limited to discrete values, not clauses such as "greater than X", so his usage is a bit different, but he is a powerful technique.
Switch <testVer>
{
Case <comparsonVal1>
{
<Code>
Break
}
Case <comparsonVal2>
{
<Code>
Break
}
Case <comparsonVal3>
{
<Code>
Break
}
Defualt:
<Code>
Break
}
5 Do...while ... Statement
int i = 1;
Do
{
console.wirteline{"{0}", i++};
}while (I < 10);
This example loops 10 times to print the 1~10 number
6 While statement
while (<Test>)
{
<code to be looped>
}
With Do...while ... Statement is different, the while statement is the first to judge the execution
7 For Loop statement
for (<initialization>;<condition>;<operation>)
{
<code to Loop>
}
8 Interrupts in the loop
8.1 Break-immediately interrupts the loop and jumps out of the loop body
8.2 Continue-immediately interrupts the current loop and resumes execution of the next loop statement
8.3 goto-can jump out of the loop to the already marked position
8.4 Return-jumps out of the loop and its included functions
C # Learning Notes (Process statements)