如何编写While循环

Kei*_*ons 8 language-agnostic conditional

你如何编写While循环的语法?

C#

int i = 0; 
while (i != 10)
{ 
   Console.WriteLine(i); 
   i++; 
}
Run Code Online (Sandbox Code Playgroud)

VB.Net

Dim i As Integer = 0
While i <> 10
    Console.WriteLine(i)
    i += 1
End While  
Run Code Online (Sandbox Code Playgroud)

PHP

<?php
while(CONDITION)
{
//Do something here.
}
?>


<?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch_assoc($result))
{
$_SESSION['fName'] = $row['fName'];
$_SESSION['lName'] = $row['lName'];
//...
}
?>
Run Code Online (Sandbox Code Playgroud)

蟒蛇

i = 0
while i != 10:
    print i
    i += 1
Run Code Online (Sandbox Code Playgroud)

Unk*_*ech 5

在PHP中,while循环将如下所示:

<?php
while(CONDITION)
{
//Do something here.
}
?>
Run Code Online (Sandbox Code Playgroud)

一个现实世界的例子可能看起来像这样

<?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch_assoc($result))
{
$_SESSION['fName'] = $row['fName'];
$_SESSION['lName'] = $row['lName'];
//...
}
?>
Run Code Online (Sandbox Code Playgroud)


Bla*_*rad 5

这类问题可能存在,但前提是答案是正确的.While不是C#中的关键字.while是.此外,之间的空间!=无效.尝试:

int i=0; 
while (i != 10)
{ 
    Console.WriteLine(i); 
    i++; 
}
Run Code Online (Sandbox Code Playgroud)

我在这里,Python:

i = 0
while i != 10:
    print i
    i += 1
Run Code Online (Sandbox Code Playgroud)