Difference between while & do while in C#
While | Do While |
Syntax | |
While(condition) { //Do Code Here } |
do{ // Do Code Here }while(condition); |
Nature & Execution Time | |
Takes less time to execute and the code is shorter. | Takes more time to execute and code becomes longer. |
Remember | |
No semicolon(;) is used in last | You have to use semicolon(;) in last as mentioned in syntax. |
What First | |
Condition is checked first. | Condition is checked later. |
Important Point | |
Since condition is checked first, statements may or may not get executed. | Since condition is checked later, the body statements will execute at least once. |
0 comments:
Post a comment