Note on getting caught in while loops. (#20230)

This commit is contained in:
Cory Harkins
2018-10-28 13:25:10 -04:00
committed by Tom
parent 4f2226ca86
commit e7fd282cde

View File

@ -27,7 +27,7 @@ while (i < 5)
## Other Uses ## 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 ```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. 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 ### Sources
* [Microsoft C# - while](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/while) * [Microsoft C# - while](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/while)