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
|
||||
- foreach
|
||||
> For the rest of the document, something between `<>`is something mandatory and something between `[]`is something optionnal
|
||||
## While loop
|
||||
## Iteration statements
|
||||
### While loop
|
||||
```cs
|
||||
while (<condition>)
|
||||
{
|
||||
@ -24,7 +25,7 @@ unit SumWhile(unit n)
|
||||
return loop;
|
||||
}
|
||||
```
|
||||
### Iteration statements - do (..) while
|
||||
#### Iteration statements - do (..) while
|
||||
```cs
|
||||
do
|
||||
{
|
||||
@ -46,7 +47,7 @@ uint SumDoWhile(uint n)
|
||||
}
|
||||
```
|
||||
|
||||
## For loop
|
||||
### For loop
|
||||
```cs
|
||||
for ([initialize]; [condition]; [iterator])
|
||||
{
|
||||
@ -99,10 +100,8 @@ foreach (char c in test)
|
||||
|
||||
## Jump statements
|
||||
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``
|
||||
- ``continue``
|
||||
- ``return``
|
||||
> ⚠️ It's not a good idea to use them, but rather to rework your loop correctly instead
|
||||
|
||||
### Jump statements - break
|
||||
> ⚠️ It's not a good idea to use them, but rather to rework your loop correctly instead
|
Loading…
x
Reference in New Issue
Block a user