您的位置:首页 > 编程语言 > C#

C#学习之While循环

2015-08-12 20:17 435 查看
While语句:while(布尔表达式) 嵌入语句;

注意:while语句能够按照不同的条件执行一个嵌入语句0次或多次。


举例:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace While循环
{
class Program
{
static void Main(string[] args)
{
int myInt = 0;
while (myInt < 10)
{
Console.WriteLine("{0}", myInt);
myInt++;
}
}
}
}


输出为:
0
1
2
3
4
5
6
7
8
9
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: