Python 官方文档:入门教程 => 点击学习
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; name
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Output do{.. break;} while() result");
int i = 1;
do
{
if ((i % 2) == 0)
break;
Console.WriteLine("{0}",i++);
}
while(i<=10);
//break, 立即终止循环;执行后面语句
Console.WriteLine("Output do{.. continue;} while() result");
int j= 1;
do
{
if ((j++ % 2) == 0)
Console.WriteLine("{0}", j);
continue;
}
while (j <= 10);
//continue, 终止当前循环;执行下一个循环;
Console.WriteLine("Output do{.. break;} while(true) result");
int k = 1;
do
{
if ((k++ % 2) == 0)
Console.WriteLine("{0}", k);
break;
}
while (true);
//死循环,用break跳出循环;
Console.WriteLine("Output do{.. continue;} while(true) result");
int z= 1;
do
{
if ((z % 2) == 0)
continue;
Console.WriteLine("{0}", z++);
}
while (true);
//死循环,continue,关闭程序跳出循环;
Console.ReadLine();
}
}
}
--结束END--
本文标题: 3. C# break,continue
本文链接: https://www.lsjlt.com/news/187577.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0