当前位置:网站首页>C # process control statement

C # process control statement

2022-06-09 02:34:00 Songyulong's blog

C# if else

if ( Boolean expression )
{
Sentence block ;
}

if ( Boolean expression )
{
Sentence block 1;
} else {
Sentence block 2;
}

if ( Boolean expression 1)
{
Sentence block 1;
} else if ( Boolean expression 2) {
Sentence block 2;

} else {
Sentence block n;
}

C# switch case

switch( expression )
{
case value 1:
Sentence block 1;
break;
case value 2:
Sentence block 2;
break;

default:
Sentence block n;
break;
}

C# for loop

for( expression 1; expression 2; expression 3)
{
expression 4;
}

  • expression 1: Give an initial value to a loop variable .
  • expression 2: Set cycle conditions for the cycle , Usually Boolean expressions .
  • expression 3: Used to change the size of the loop variable .
  • expression 4: The expression is executed when the loop condition is met 4.

C# foreach loop

foreach( data type Variable name in Traversing objects )
{
Sentence block
}

C# while loop

while( Boolean expression )
{
Sentence block ;
}

C# do while loop

do
{
Sentence block ;
}while( Boolean expression );

C# break

Used to jump out of the current loop , Such as for loop 、while loop 、switch-case etc. .

C# continue

about for loop ,continue Statements cause conditional tests and loop increment parts to be executed . about while and do while loop ,continue Statement will cause program control to return to conditional testing .

C# goto

goto Labell;
Sentence block 1;
Labell
Sentence block 2;

原网站

版权声明
本文为[Songyulong's blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090224015079.html