Synchronization of old projects
Part1
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user