Synchronization of old projects

Part1
This commit is contained in:
2025-09-30 16:46:01 +08:00
parent 116b65164b
commit 4e1548abe2
167 changed files with 8668 additions and 43 deletions
@@ -0,0 +1,64 @@
using System;
namespace Lesson18_循环语句while
{
class Program
{
static void Main(string[] args)
{
#region
// 让程序重复执行某段代码,直到满足特定条件为止。
#endregion
#region
// while (bool类型的值)
// {
// // 需要循环执行的代码
// }
//进入unity之后 基本不会使用while循环
while (true)
{
Console.WriteLine("#");
// 这里的代码如果不被结束会一直执行
// 这种无限循环会导致程序无法结束,除非手动停止。
break; // 这里的 break 语句可以用来跳出循环
}
#endregion
#region 使
int a = 0;
int b = 0;
while (a < 5)
{
Console.WriteLine("#");
a++;
while (b < 5)
{
Console.WriteLine("*");
b++;
}
}
#endregion
#region
int count = 0;
while (count < 5)
{
Console.WriteLine("*");
count++;
if (count == 3)
{
Console.WriteLine("跳过当前循环");
continue; // 跳过当前循环的剩余部分,直接进入下一次循环
}
if (count == 4)
{
Console.WriteLine("结束循环");
break; // 结束整个循环
}
Console.WriteLine("当前计数: " + count);
}
#endregion
}
}
}