码迷,mamicode.com
首页 > Windows程序 > 详细

15.C#--break的使用

时间:2019-04-20 11:25:40      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:stat   void   定义   跳出循环   write   ++   while循环   static   rgs   

static void Main(string[] args)
{
//break的用法:主要用于跳出循环体
//定义i和j二个变量,用于存储循环次数
int i = 1;
int j = 1;
while (i <= 10)
{
while (j <= 10)
{
Console.WriteLine("我是里面的while循环");
j++;
break; //跳出内循环,继续执行外循环
}
Console.WriteLine("我是外面的while循环");
i++;
}
Console.ReadKey();
}

15.C#--break的使用

标签:stat   void   定义   跳出循环   write   ++   while循环   static   rgs   

原文地址:https://blog.51cto.com/12679593/2381763

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!