根据指定的条件表达式, 如果条件为true
, 就循序执行程序,如果条件为 false
,就结束循环.
![](https://gitee.com/guapit_com/mt5-tutorial-pictures/raw/master/images/mt5/gp-20221114030534.png)
![](https://guapit.com/wp-content/uploads/2022/11/image-1024x697.png)
while(条件表达式)
{
执行程序;
}
int index = 0;
while(index < 10)
{
Print("当前index的值: " + string(index));
}
代码实现
void OnStart()
{
// do while循环语句
int index = 0;
// do里面的执行程序,会至少执行一次
do
{
// 执行程序
if (index == 0)
{
Print("循环程序开始...");
Print("index的值: " + string(index));
}
else
{
Print("index的值: " + string(index));
}
index++;
}
while (index < 5);
}