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>
@@ -0,0 +1,29 @@
using System;
namespace lesson15
{
class program
{
static void Main(string[] args)
{
#region
// 套路: 3个空位 2个符号
// 固定语法:空位 ?空位 :空位
// 关键信息:bool类型 ?bool类型为真返回内容 :bool类型为假返回内容
// 三目运算符会有返回值,这个返回值类型必须一致且必须被使用
#endregion
#region
string str = true ? "条件为真" : "条件为假";
Console.WriteLine(str);// 输出:条件为真
str = false ? "条件为真" : "条件为假";
Console.WriteLine(str);// 输出:条件为假
int a = 5;
str = a > 1 ? "a大于1" : "a小于等于1";
bool b = a > 1 ? a > 6 : !false;
Console.WriteLine(b);// 输出:False
#endregion
}
}
}