Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
namespace Lesson19_循环语句dowhile
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#region 知识点一 基本语法
|
||||
//和while循环类似,do while循环也是一种循环语句。
|
||||
//区别在于do while循环会先执行一次循环体,然后再判断条件是否满足。
|
||||
//do while循环的语法如下:
|
||||
//do
|
||||
//{
|
||||
// // 循环体
|
||||
//} while (条件);
|
||||
//do while循环会先执行一次循环体,然后再判断条件是否满足。
|
||||
#endregion
|
||||
|
||||
#region 知识点二 使用示例
|
||||
int a = 1;
|
||||
do
|
||||
{
|
||||
Console.WriteLine("a的值是{0}",a);
|
||||
a++;
|
||||
break;//防止死循环
|
||||
} while (a>=2);
|
||||
#endregion
|
||||
|
||||
#region 知识点三 嵌套应用和流程语句
|
||||
//if switch while dowhile都可以嵌套使用
|
||||
do
|
||||
{
|
||||
Console.WriteLine("111");
|
||||
continue;//这个循环只会打印一边111,continue是回到while判断的地方而不是回到do
|
||||
Console.WriteLine("222");//这串代码永远不会被运行
|
||||
} while (false);
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user