0

What is use of while (false) while(true) and how to use it?

29th Sep 2016, 7:26 AM
Manoj
8 Respostas
+ 9
If the condition in true then it will enter the while loop. Otherwise , it will skip the while.
22nd Oct 2016, 1:18 PM
Remmae
Remmae - avatar
+ 6
I'm not sure of a use for while (false), even if it were used in a do/while to run at least one time. while (true) can be useful for unpredictable loops that depend on things like user input, random numbers, files, etc.. With whatever condition(s) you set to leave the loop, you use the keyword break to exit the loop when they're met. Example: while (true) { //your code //Y/N loop if (yn.ToUpper() == 'N') break; } It's the same as if a condition had been put at the top instead, like while(yn.ToUpper() == 'Y') so it's a matter of preference where you want it.
29th Sep 2016, 5:38 PM
Tamra
Tamra - avatar
+ 4
false to skip this loop only.
24th Oct 2016, 10:36 AM
Ali Hussein Ali
Ali Hussein Ali - avatar
+ 2
while loops use only Boolean expression and when it is true. So when it gets true it'll execute until it gets false. while(false) means the condition is false which will end the loop. while(True) means the condition is True which will continue the loop.
20th Oct 2016, 12:16 AM
Md. Boshirul Islam Khan
Md. Boshirul Islam Khan - avatar
+ 1
while(true) in an infinite loop
29th Sep 2016, 8:29 PM
shahrad
0
while (true) is covered by Tamra, while(false) could be used to temporarily skip the while loop when debugging code.
16th Nov 2016, 4:02 PM
Tom
Tom - avatar
0
dowhile loop execution at least one time not matter conditions true or false
16th Dec 2016, 12:40 PM
Hejbullah Afsari
Hejbullah Afsari - avatar
0
Which condition is the while loop checking to be true or false?
9th Mar 2018, 1:17 PM
Apoorv
Apoorv - avatar