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,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+99
View File
@@ -0,0 +1,99 @@
using System;
namespace Lesson16
{
class program
{
static void Main(string[] args)
{
#region
//让顺序执行的代码 产生分支
//
#endregion
#region if语句
//作用:满足条件时 多执行一些代码
//语法:
//if (条件表达式) { 代码块 }
//if (条件表达式) { 代码块 } else { 代码块 }
//if (条件表达式) { 代码块 } else if (条件表达式) { 代码块 } else { 代码块 }
//条件表达式:返回true或false的bool值表达式
//只有返回值为true时,代码块才会执行
//else:可选,表示条件不满足时执行的代码块
//注意:
//1.if语句条件表达式部分不用写分号
//2.if语句可以嵌套使用
//
Console.WriteLine("这是代码块外的代码");
if (true)
{
Console.WriteLine("进入了if语句代码块,执行了其中的代码逻辑");
}//会被执行打印
Console.WriteLine("这是代码块外的代码");
if (false)
{
Console.WriteLine("进入了if语句代码块,执行了其中的代码逻辑");
}//不会被执行
//例子
int a = 1;
if (a == 1)
{
Console.WriteLine("满足a == 1条件");
}
a = 1;
if (a >= 0 && a <= 5)
{
Console.WriteLine("满足0<a<5条件");
}
//例子2
string name = "HK";
string passWord = "666";
if ( name == "HK" && passWord == "666" )
{
Console.WriteLine("登录成功");
}
//嵌套使用例子
if ( name == "HK")
{
Console.WriteLine("用户名可用");
if ( passWord == "666")
{
Console.WriteLine("密码验证成功");
}
}
//if else例子
//注意:
//1.if else语句中else部分的条件表达式是可选的
//2.else部分的代码块会在if条件不满足时执行
//3.在第一个else if被执行后,后续的else if和else部分将不会被执行,这样可以避免多次执行代码块
if (name == "HK")
{
Console.WriteLine("用户名可用");
}
else
{
Console.WriteLine("用户名不可用");
}
//if else if 例子
if (name == "HK")
{
Console.WriteLine("用户名可用");
}
else if (name == "HK2")
{
Console.WriteLine("用户名可用2");
}
else
{
Console.WriteLine("用户名不可用");
}
#endregion
}
}
}