Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
namespace Lesson19_循环语句for
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#region 知识点一 基本语法
|
||||
//格式
|
||||
//for (初始表达式; 条件表达式; 增量表达式)
|
||||
//{
|
||||
// //循环代码
|
||||
//}
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Console.WriteLine("这时的i为{0}",i);
|
||||
}
|
||||
Console.WriteLine("\n换行\n");
|
||||
#endregion
|
||||
|
||||
#region 知识点二 支持嵌套
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
Console.WriteLine("i的值为{0},j的值为{1}", i, j);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 知识点三 特殊写法
|
||||
for (; ; )//空位可填可不填
|
||||
{
|
||||
Console.WriteLine("这是一个死循环");
|
||||
break;//用break跳出死循环
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 知识点四 对比while循环
|
||||
int j = 0;
|
||||
while (j < 10)
|
||||
{
|
||||
Console.WriteLine("j为{0}",j);
|
||||
}
|
||||
j=0;//重置j
|
||||
for (; j < 10; )//初始表达式和增量表达式可省略
|
||||
{
|
||||
Console.WriteLine("j为{0}", j);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user