Files
freeCodeCamp/guide/english/csharp/do-while-loop/index.md
Nitin Sharma 35c38ce5f4 Simplified language. (#32814)
Simplified the language, removing duplicate phrases.
Also did little formatting.
2019-05-11 22:06:13 +05:30

41 lines
919 B
Markdown

---
title: Do while loop
---
# Do while Loop
The `do while` loop executes a block of code atleast once and until a condition is false. It is a particular case of <a href='https://guide.freecodecamp.org/csharp/while-loop' target='_blank' rel='nofollow'>`while` loop</a> in which the code is executed atleast once irrespective of the while condition. A common use of `do while` loops are input checks.
## Example
```
do
{
//execute code block
} while(boolean expression);
string input = "";
do
{
Console.WriteLine("Type A to continue: ");
input = Console.ReadLine();
} while(input != "A");
Console.WriteLine("Bye!");
```
## Output:
```
> Type A to continue: b
> Type A to continue: g
> Type A to continue: A
> Bye!
```
#### More Information:
* [Microsoft C# - do](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/do)
* [Dot Net Perls - do](https://www.dotnetperls.com/do)