Note on getting caught in while loops. (#20230)
This commit is contained in:
@ -27,7 +27,7 @@ while (i < 5)
|
||||
|
||||
## Other Uses
|
||||
|
||||
The while loops is often used for infinite iterrations by using (for example) `while (true)`, only to be ended through a condition unrelated to the initial condition of the loop.
|
||||
The while loops is often used for infinite iterrations by using (for example) `while (true)`, only to be ended through a condition unrelated to the initial condition of the loop. Be careful to not get stuck in an infinite loop when using while loops in this manner.
|
||||
|
||||
|
||||
```csharp
|
||||
@ -49,6 +49,7 @@ while (true)
|
||||
|
||||
The biggest differences between the `for` and `while` loops is that `while` is typically used when a developer is not sure of an exact number of iterations of the loop, and `for` is used when it's clear how many times to iterate through code.
|
||||
|
||||
|
||||
### Sources
|
||||
* [Microsoft C# - while](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/while)
|
||||
|
||||
|
Reference in New Issue
Block a user