vault backup: 2023-10-05 16:25:30
This commit is contained in:
parent
b88b928772
commit
be54a105c5
@ -3,7 +3,8 @@ In C#, loops are called iteration statements. We need to master both, recursion
|
|||||||
- for
|
- for
|
||||||
- foreach
|
- foreach
|
||||||
> For the rest of the document, something between `<>`is something mandatory and something between `[]`is something optionnal
|
> For the rest of the document, something between `<>`is something mandatory and something between `[]`is something optionnal
|
||||||
## While loop
|
## Iteration statements
|
||||||
|
### While loop
|
||||||
```cs
|
```cs
|
||||||
while (<condition>)
|
while (<condition>)
|
||||||
{
|
{
|
||||||
@ -24,7 +25,7 @@ unit SumWhile(unit n)
|
|||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
### Iteration statements - do (..) while
|
#### Iteration statements - do (..) while
|
||||||
```cs
|
```cs
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -46,7 +47,7 @@ uint SumDoWhile(uint n)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## For loop
|
### For loop
|
||||||
```cs
|
```cs
|
||||||
for ([initialize]; [condition]; [iterator])
|
for ([initialize]; [condition]; [iterator])
|
||||||
{
|
{
|
||||||
@ -99,10 +100,8 @@ foreach (char c in test)
|
|||||||
|
|
||||||
## Jump statements
|
## Jump statements
|
||||||
Jump statements is something that can change the behaviour of a loop inside itself.
|
Jump statements is something that can change the behaviour of a loop inside itself.
|
||||||
It's possible to change the behaviour of the loops using the following keyworkds:
|
It's possible to change the behaviour of the loops using the following keywords:
|
||||||
- ``break``
|
- ``break``
|
||||||
- ``continue``
|
- ``continue``
|
||||||
- ``return``
|
- ``return``
|
||||||
> ⚠️ It's not a good idea to use them, but rather to rework your loop correctly instead
|
> ⚠️ It's not a good idea to use them, but rather to rework your loop correctly instead
|
||||||
|
|
||||||
### Jump statements - break
|
|
Loading…
x
Reference in New Issue
Block a user