From 4e1548abe24984eda83b764085f3957a7f188fbd Mon Sep 17 00:00:00 2001
From: Kister Hakusan <2753888203@qq.com>
Date: Tue, 30 Sep 2025 16:46:01 +0800
Subject: [PATCH] Synchronization of old projects Part1
---
C#入门/C#入门.sln | 211 +++++++
C#入门/Csharp入门.sln | 43 --
.../Lesson10_算数运算符.csproj | 10 +
C#入门/Lesson10_算数运算符/Program.cs | 140 +++++
.../Lesson10_算数运算符练习.csproj | 10 +
C#入门/Lesson10_算数运算符练习/Program.cs | 55 ++
.../Lesson11_字符串拼接.csproj | 10 +
C#入门/Lesson11_字符串拼接/Program.cs | 68 +++
.../Lesson11_字符串拼接练习.csproj | 10 +
C#入门/Lesson11_字符串拼接练习/Program.cs | 35 ++
C#入门/Lesson11_练习题/Lesson11_练习题.csproj | 10 +
C#入门/Lesson11_练习题/Program.cs | 23 +
.../Lesson12_条件运算符.csproj | 10 +
C#入门/Lesson12_条件运算符/Program.cs | 88 +++
.../Lesson12_条件运算符练习.csproj | 10 +
C#入门/Lesson12_条件运算符练习/Program.cs | 35 ++
.../Lesson13_ 逻辑运算符.csproj | 11 +
C#入门/Lesson13_ 逻辑运算符/Program.cs | 82 +++
.../Lesson13_逻辑运算符练习.csproj | 10 +
C#入门/Lesson13_逻辑运算符练习/Program.cs | 27 +
C#入门/Lesson14_位运算/Lesson14_位运算.csproj | 10 +
C#入门/Lesson14_位运算/Program.cs | 64 ++
.../Lesson14_位运算练习.csproj | 10 +
C#入门/Lesson14_位运算练习/Program.cs | 31 +
.../Lesson15_三目运算符.csproj | 10 +
C#入门/Lesson15_三目运算符/Program.cs | 29 +
.../Lesson15_三目运算符练习.csproj | 10 +
C#入门/Lesson15_三目运算符练习/Program.cs | 18 +
.../Lesson16_条件分支语句if.csproj | 10 +
C#入门/Lesson16_if语句/Program.cs | 99 ++++
.../Lesson16_条件分支语句if练习.csproj | 10 +
C#入门/Lesson16_if语句练习/Program.cs | 146 +++++
.../Lesson17_条件分支语句Switch.csproj | 10 +
C#入门/Lesson17_条件分支语句Switch/Program.cs | 114 ++++
.../Lesson17_条件分支语句Switch练习.csproj | 10 +
.../Lesson17_条件分支语句Switch练习/Program.cs | 135 +++++
.../Lesson18_循环语句while.csproj | 10 +
C#入门/Lesson18_循环语句while/Program.cs | 64 ++
.../Lesson19_循环语句dowhile.csproj | 10 +
C#入门/Lesson19_循环语句dowhile/Program.cs | 41 ++
.../Lesson20_循环语句for.csproj | 10 +
C#入门/Lesson19_循环语句for/Program.cs | 53 ++
C#入门/Lesson2变量练习/Lesson2变量练习.csproj | 10 +
C#入门/Lesson2变量练习/Program.cs | 21 +
.../Lesson4变量的命名规则.csproj | 10 +
C#入门/Lesson4变量的命名规则/Program.cs | 51 ++
C#入门/Lesson5常量/Lesson5常量.csproj | 10 +
C#入门/Lesson5常量/Program.cs | 35 ++
C#入门/Lesson6转义字符/Lesson6转义字符.csproj | 10 +
C#入门/Lesson6转义字符/Program.cs | 29 +
.../Lesson7转义字符练习.csproj | 10 +
C#入门/Lesson7转义字符练习/Program.cs | 13 +
.../Lesson7隐式转换_类型转换.csproj | 10 +
C#入门/Lesson7隐式转换_类型转换/Program.cs | 156 +++++
.../Lesson8_显式转换练习.csproj | 10 +
C#入门/Lesson8_显式转换联系/Program.cs | 28 +
.../Lesson8_显示转换/Lesson8_显式转换.csproj | 10 +
C#入门/Lesson8_显示转换/Program.cs | 177 ++++++
.../Lesson9_异常捕获/Lesson9_异常捕获.csproj | 10 +
C#入门/Lesson9_异常捕获/Program.cs | 52 ++
.../Lesson9_捕获异常练习.csproj | 10 +
C#入门/Lesson9_捕获异常联系/Program.cs | 50 ++
C#入门实践教程/C#入门实践教程.sln | 49 ++
C#入门实践教程/小游戏/Program.cs | 370 ++++++++++++
C#入门实践教程/小游戏/小游戏.csproj | 10 +
.../必备知识点_控制台相关/Program.cs | 70 +++
.../必备知识点_控制台相关.csproj | 10 +
C#入门实践教程/练习题/Program.cs | 68 +++
C#入门实践教程/练习题/控制台相关练习题.csproj | 10 +
C#入门实践教程/随机数/Program.cs | 24 +
C#入门实践教程/随机数/随机数.csproj | 10 +
C#入门实践教程/随机数相关练习题/Program.cs | 34 ++
.../随机数相关练习题/随机数相关练习题.csproj | 10 +
C#基础/C#基础.sln | 175 ++++++
.../Lesson10_函数重载/Lesson10_函数重载.csproj | 10 +
C#基础/Lesson10_函数重载/Program.cs | 90 +++
.../Lesson10_函数重载练习.csproj | 10 +
C#基础/Lesson10_函数重载练习/Program.cs | 91 +++
.../Lesson11_递归函数/Lesson11_递归函数.csproj | 10 +
C#基础/Lesson11_递归函数/Program.cs | 45 ++
.../Lesson11_递归函数练习.csproj | 10 +
C#基础/Lesson11_递归函数练习/Program.cs | 80 +++
C#基础/Lesson12_结构体/Lesson12_结构体.csproj | 10 +
C#基础/Lesson12_结构体/Program.cs | 115 ++++
.../Lesson12_结构体练习.csproj | 10 +
C#基础/Lesson12_结构体练习/Program.cs | 179 ++++++
.../Lesson13_冒泡排序/Lesson13_冒泡排序.csproj | 10 +
C#基础/Lesson13_冒泡排序/Program.cs | 69 +++
.../Lesson13_冒泡排序练习.csproj | 10 +
C#基础/Lesson13_冒泡排序练习/Program.cs | 59 ++
.../Lesson14_选择排序/Lesson14_选择排序.csproj | 10 +
C#基础/Lesson14_选择排序/Program.cs | 77 +++
.../Lesson14_选择排序练习.csproj | 10 +
C#基础/Lesson14_选择排序练习/Program.cs | 64 ++
.../Lesson1_ 枚举练习/Lesson1_ 枚举练习.csproj | 11 +
C#基础/Lesson1_ 枚举练习/Program.cs | 155 +++++
C#基础/Lesson1_枚举/Lesson1_枚举.csproj | 10 +
C#基础/Lesson1_枚举/Program.cs | 116 ++++
.../Lesson2_一维数组/Lesson2_一维数组.csproj | 10 +
C#基础/Lesson2_一维数组/Program.cs | 130 +++++
.../Lesson2_一维数组练习.csproj | 10 +
C#基础/Lesson2_数组练习/Program.cs | 199 +++++++
.../Lesson3_二维数组/Lesson3_二维数组.csproj | 10 +
C#基础/Lesson3_二维数组/Program.cs | 171 ++++++
.../Lesson3_二维数组练习题.csproj | 10 +
C#基础/Lesson3_二维数组练习题/Program.cs | 180 ++++++
.../Lesson4_交错数组/Lesson4_交错数组.csproj | 10 +
C#基础/Lesson4_交错数组/Program.cs | 58 ++
.../Lesson5_值类型和引用类型.csproj | 10 +
C#基础/Lesson5_值类型和引用类型/Program.cs | 63 ++
.../Lesson6_特殊的引用类型string.csproj | 10 +
.../Lesson6_特殊的引用类型string/Program.cs | 35 ++
C#基础/Lesson7_函数/Lesson7_函数.csproj | 10 +
C#基础/Lesson7_函数/Program.cs | 138 +++++
.../Lesson7_函数练习/Lesson7_函数练习.csproj | 10 +
C#基础/Lesson7_函数练习/Program.cs | 85 +++
.../Lesson8_ref和out/Lesson8_ref和out.csproj | 10 +
C#基础/Lesson8_ref和out/Program.cs | 144 +++++
.../Lesson8_ref和out练习.csproj | 10 +
C#基础/Lesson8_ref和out练习/Program.cs | 51 ++
.../Lesson9_变长参数和参数默认值.csproj | 10 +
.../Lesson9_变长参数和参数默认值/Program.cs | 69 +++
.../Lesson9_变长参数和参数默认值练习.csproj | 10 +
.../Lesson9_变长参数和参数默认值练习/Program.cs | 60 ++
C#基础/test/Program.cs | 28 +
C#基础/test/test.csproj | 10 +
C#基础实践教程/C#基础实践教程.sln | 25 +
.../C#基础实践教程/C#基础实践教程.csproj | 11 +
C#基础实践教程/C#基础实践教程/Program.cs | 548 ++++++++++++++++++
C#核心/C#核心/Program.cs | 2 +
C#核心/C#核心/test.csproj | 11 +
.../Lesson1_类和对象/Lesson1_类和对象.csproj | 10 +
C#核心/Lesson1_类和对象/Program.cs | 91 +++
.../Lesson1_类和对象练习.csproj | 10 +
C#核心/Lesson1_类和对象练习/Program.cs | 10 +
.../Lesson2_封装-成员变量和访问修饰符.csproj | 10 +
.../Lesson2_成员变量和访问修饰符/Program.cs | 118 ++++
.../Lesson2_封装-成员变量和访问修饰符练习.csproj | 10 +
.../Lesson2_成员变量和访问修饰符练习/Program.cs | 68 +++
.../Lesson3_封装-成员方法.csproj | 11 +
C#核心/Lesson3_封装-成员方法/Program.cs | 77 +++
.../Lesson3_封装-成员方法练习.csproj | 11 +
C#核心/Lesson3_封装-成员方法练习/Program.cs | 66 +++
.../Lesson4_封装-构造函数和析构函数.csproj | 11 +
.../Lesson4_封装-构造函数和析构函数/Program.cs | 165 ++++++
.../Lesson4_封装-构造函数和析构函数练习.csproj | 11 +
.../Program.cs | 101 ++++
.../Lesson5_封装-成员属性.csproj | 11 +
C#核心/Lesson5_封装-成员属性/Program.cs | 165 ++++++
.../Lesson5_封装-成员属性练习.csproj | 11 +
C#核心/Lesson5_封装-成员属性练习/Program.cs | 129 +++++
.../Lesson6_封装-索引器.csproj | 11 +
C#核心/Lesson6_封装-索引器/Program.cs | 130 +++++
.../Lesson6_封装-索引器练习.csproj | 11 +
C#核心/Lesson6_封装-索引器练习/Program.cs | 145 +++++
.../Lesson7_封装-静态成员.csproj | 10 +
C#核心/Lesson7_静态成员/Program.cs | 96 +++
.../Lesson7_封装-静态成员练习.csproj | 10 +
C#核心/Lesson7_静态成员练习/Program.cs | 38 ++
.../Lesson8_封装-静态类和静态构造函数.csproj | 11 +
.../Program.cs | 125 ++++
.../Lesson8_封装-静态类和静态构造函数练习.csproj | 11 +
.../Program.cs | 48 ++
.../Lesson9_封装-拓展方法.csproj | 11 +
C#核心/Lesson9_封装-拓展方法/Program.cs | 117 ++++
.../Lesson9_封装-拓展方法练习.csproj | 11 +
C#核心/Lesson9_封装-拓展方法练习/Program.cs | 67 +++
167 files changed, 8668 insertions(+), 43 deletions(-)
create mode 100644 C#入门/C#入门.sln
delete mode 100644 C#入门/Csharp入门.sln
create mode 100644 C#入门/Lesson10_算数运算符/Lesson10_算数运算符.csproj
create mode 100644 C#入门/Lesson10_算数运算符/Program.cs
create mode 100644 C#入门/Lesson10_算数运算符练习/Lesson10_算数运算符练习.csproj
create mode 100644 C#入门/Lesson10_算数运算符练习/Program.cs
create mode 100644 C#入门/Lesson11_字符串拼接/Lesson11_字符串拼接.csproj
create mode 100644 C#入门/Lesson11_字符串拼接/Program.cs
create mode 100644 C#入门/Lesson11_字符串拼接练习/Lesson11_字符串拼接练习.csproj
create mode 100644 C#入门/Lesson11_字符串拼接练习/Program.cs
create mode 100644 C#入门/Lesson11_练习题/Lesson11_练习题.csproj
create mode 100644 C#入门/Lesson11_练习题/Program.cs
create mode 100644 C#入门/Lesson12_条件运算符/Lesson12_条件运算符.csproj
create mode 100644 C#入门/Lesson12_条件运算符/Program.cs
create mode 100644 C#入门/Lesson12_条件运算符练习/Lesson12_条件运算符练习.csproj
create mode 100644 C#入门/Lesson12_条件运算符练习/Program.cs
create mode 100644 C#入门/Lesson13_ 逻辑运算符/Lesson13_ 逻辑运算符.csproj
create mode 100644 C#入门/Lesson13_ 逻辑运算符/Program.cs
create mode 100644 C#入门/Lesson13_逻辑运算符练习/Lesson13_逻辑运算符练习.csproj
create mode 100644 C#入门/Lesson13_逻辑运算符练习/Program.cs
create mode 100644 C#入门/Lesson14_位运算/Lesson14_位运算.csproj
create mode 100644 C#入门/Lesson14_位运算/Program.cs
create mode 100644 C#入门/Lesson14_位运算练习/Lesson14_位运算练习.csproj
create mode 100644 C#入门/Lesson14_位运算练习/Program.cs
create mode 100644 C#入门/Lesson15_三目运算符/Lesson15_三目运算符.csproj
create mode 100644 C#入门/Lesson15_三目运算符/Program.cs
create mode 100644 C#入门/Lesson15_三目运算符练习/Lesson15_三目运算符练习.csproj
create mode 100644 C#入门/Lesson15_三目运算符练习/Program.cs
create mode 100644 C#入门/Lesson16_if语句/Lesson16_条件分支语句if.csproj
create mode 100644 C#入门/Lesson16_if语句/Program.cs
create mode 100644 C#入门/Lesson16_if语句练习/Lesson16_条件分支语句if练习.csproj
create mode 100644 C#入门/Lesson16_if语句练习/Program.cs
create mode 100644 C#入门/Lesson17_条件分支语句Switch/Lesson17_条件分支语句Switch.csproj
create mode 100644 C#入门/Lesson17_条件分支语句Switch/Program.cs
create mode 100644 C#入门/Lesson17_条件分支语句Switch练习/Lesson17_条件分支语句Switch练习.csproj
create mode 100644 C#入门/Lesson17_条件分支语句Switch练习/Program.cs
create mode 100644 C#入门/Lesson18_循环语句while/Lesson18_循环语句while.csproj
create mode 100644 C#入门/Lesson18_循环语句while/Program.cs
create mode 100644 C#入门/Lesson19_循环语句dowhile/Lesson19_循环语句dowhile.csproj
create mode 100644 C#入门/Lesson19_循环语句dowhile/Program.cs
create mode 100644 C#入门/Lesson19_循环语句for/Lesson20_循环语句for.csproj
create mode 100644 C#入门/Lesson19_循环语句for/Program.cs
create mode 100644 C#入门/Lesson2变量练习/Lesson2变量练习.csproj
create mode 100644 C#入门/Lesson2变量练习/Program.cs
create mode 100644 C#入门/Lesson4变量的命名规则/Lesson4变量的命名规则.csproj
create mode 100644 C#入门/Lesson4变量的命名规则/Program.cs
create mode 100644 C#入门/Lesson5常量/Lesson5常量.csproj
create mode 100644 C#入门/Lesson5常量/Program.cs
create mode 100644 C#入门/Lesson6转义字符/Lesson6转义字符.csproj
create mode 100644 C#入门/Lesson6转义字符/Program.cs
create mode 100644 C#入门/Lesson7转义字符练习/Lesson7转义字符练习.csproj
create mode 100644 C#入门/Lesson7转义字符练习/Program.cs
create mode 100644 C#入门/Lesson7隐式转换_类型转换/Lesson7隐式转换_类型转换.csproj
create mode 100644 C#入门/Lesson7隐式转换_类型转换/Program.cs
create mode 100644 C#入门/Lesson8_显式转换联系/Lesson8_显式转换练习.csproj
create mode 100644 C#入门/Lesson8_显式转换联系/Program.cs
create mode 100644 C#入门/Lesson8_显示转换/Lesson8_显式转换.csproj
create mode 100644 C#入门/Lesson8_显示转换/Program.cs
create mode 100644 C#入门/Lesson9_异常捕获/Lesson9_异常捕获.csproj
create mode 100644 C#入门/Lesson9_异常捕获/Program.cs
create mode 100644 C#入门/Lesson9_捕获异常联系/Lesson9_捕获异常练习.csproj
create mode 100644 C#入门/Lesson9_捕获异常联系/Program.cs
create mode 100644 C#入门实践教程/C#入门实践教程.sln
create mode 100644 C#入门实践教程/小游戏/Program.cs
create mode 100644 C#入门实践教程/小游戏/小游戏.csproj
create mode 100644 C#入门实践教程/必备知识点_控制台相关/Program.cs
create mode 100644 C#入门实践教程/必备知识点_控制台相关/必备知识点_控制台相关.csproj
create mode 100644 C#入门实践教程/练习题/Program.cs
create mode 100644 C#入门实践教程/练习题/控制台相关练习题.csproj
create mode 100644 C#入门实践教程/随机数/Program.cs
create mode 100644 C#入门实践教程/随机数/随机数.csproj
create mode 100644 C#入门实践教程/随机数相关练习题/Program.cs
create mode 100644 C#入门实践教程/随机数相关练习题/随机数相关练习题.csproj
create mode 100644 C#基础/C#基础.sln
create mode 100644 C#基础/Lesson10_函数重载/Lesson10_函数重载.csproj
create mode 100644 C#基础/Lesson10_函数重载/Program.cs
create mode 100644 C#基础/Lesson10_函数重载练习/Lesson10_函数重载练习.csproj
create mode 100644 C#基础/Lesson10_函数重载练习/Program.cs
create mode 100644 C#基础/Lesson11_递归函数/Lesson11_递归函数.csproj
create mode 100644 C#基础/Lesson11_递归函数/Program.cs
create mode 100644 C#基础/Lesson11_递归函数练习/Lesson11_递归函数练习.csproj
create mode 100644 C#基础/Lesson11_递归函数练习/Program.cs
create mode 100644 C#基础/Lesson12_结构体/Lesson12_结构体.csproj
create mode 100644 C#基础/Lesson12_结构体/Program.cs
create mode 100644 C#基础/Lesson12_结构体练习/Lesson12_结构体练习.csproj
create mode 100644 C#基础/Lesson12_结构体练习/Program.cs
create mode 100644 C#基础/Lesson13_冒泡排序/Lesson13_冒泡排序.csproj
create mode 100644 C#基础/Lesson13_冒泡排序/Program.cs
create mode 100644 C#基础/Lesson13_冒泡排序练习/Lesson13_冒泡排序练习.csproj
create mode 100644 C#基础/Lesson13_冒泡排序练习/Program.cs
create mode 100644 C#基础/Lesson14_选择排序/Lesson14_选择排序.csproj
create mode 100644 C#基础/Lesson14_选择排序/Program.cs
create mode 100644 C#基础/Lesson14_选择排序练习/Lesson14_选择排序练习.csproj
create mode 100644 C#基础/Lesson14_选择排序练习/Program.cs
create mode 100644 C#基础/Lesson1_ 枚举练习/Lesson1_ 枚举练习.csproj
create mode 100644 C#基础/Lesson1_ 枚举练习/Program.cs
create mode 100644 C#基础/Lesson1_枚举/Lesson1_枚举.csproj
create mode 100644 C#基础/Lesson1_枚举/Program.cs
create mode 100644 C#基础/Lesson2_一维数组/Lesson2_一维数组.csproj
create mode 100644 C#基础/Lesson2_一维数组/Program.cs
create mode 100644 C#基础/Lesson2_数组练习/Lesson2_一维数组练习.csproj
create mode 100644 C#基础/Lesson2_数组练习/Program.cs
create mode 100644 C#基础/Lesson3_二维数组/Lesson3_二维数组.csproj
create mode 100644 C#基础/Lesson3_二维数组/Program.cs
create mode 100644 C#基础/Lesson3_二维数组练习题/Lesson3_二维数组练习题.csproj
create mode 100644 C#基础/Lesson3_二维数组练习题/Program.cs
create mode 100644 C#基础/Lesson4_交错数组/Lesson4_交错数组.csproj
create mode 100644 C#基础/Lesson4_交错数组/Program.cs
create mode 100644 C#基础/Lesson5_值类型和引用类型/Lesson5_值类型和引用类型.csproj
create mode 100644 C#基础/Lesson5_值类型和引用类型/Program.cs
create mode 100644 C#基础/Lesson6_特殊的引用类型string/Lesson6_特殊的引用类型string.csproj
create mode 100644 C#基础/Lesson6_特殊的引用类型string/Program.cs
create mode 100644 C#基础/Lesson7_函数/Lesson7_函数.csproj
create mode 100644 C#基础/Lesson7_函数/Program.cs
create mode 100644 C#基础/Lesson7_函数练习/Lesson7_函数练习.csproj
create mode 100644 C#基础/Lesson7_函数练习/Program.cs
create mode 100644 C#基础/Lesson8_ref和out/Lesson8_ref和out.csproj
create mode 100644 C#基础/Lesson8_ref和out/Program.cs
create mode 100644 C#基础/Lesson8_ref和out练习/Lesson8_ref和out练习.csproj
create mode 100644 C#基础/Lesson8_ref和out练习/Program.cs
create mode 100644 C#基础/Lesson9_变长参数和参数默认值/Lesson9_变长参数和参数默认值.csproj
create mode 100644 C#基础/Lesson9_变长参数和参数默认值/Program.cs
create mode 100644 C#基础/Lesson9_变长参数和参数默认值练习/Lesson9_变长参数和参数默认值练习.csproj
create mode 100644 C#基础/Lesson9_变长参数和参数默认值练习/Program.cs
create mode 100644 C#基础/test/Program.cs
create mode 100644 C#基础/test/test.csproj
create mode 100644 C#基础实践教程/C#基础实践教程.sln
create mode 100644 C#基础实践教程/C#基础实践教程/C#基础实践教程.csproj
create mode 100644 C#基础实践教程/C#基础实践教程/Program.cs
create mode 100644 C#核心/C#核心/Program.cs
create mode 100644 C#核心/C#核心/test.csproj
create mode 100644 C#核心/Lesson1_类和对象/Lesson1_类和对象.csproj
create mode 100644 C#核心/Lesson1_类和对象/Program.cs
create mode 100644 C#核心/Lesson1_类和对象练习/Lesson1_类和对象练习.csproj
create mode 100644 C#核心/Lesson1_类和对象练习/Program.cs
create mode 100644 C#核心/Lesson2_成员变量和访问修饰符/Lesson2_封装-成员变量和访问修饰符.csproj
create mode 100644 C#核心/Lesson2_成员变量和访问修饰符/Program.cs
create mode 100644 C#核心/Lesson2_成员变量和访问修饰符练习/Lesson2_封装-成员变量和访问修饰符练习.csproj
create mode 100644 C#核心/Lesson2_成员变量和访问修饰符练习/Program.cs
create mode 100644 C#核心/Lesson3_封装-成员方法/Lesson3_封装-成员方法.csproj
create mode 100644 C#核心/Lesson3_封装-成员方法/Program.cs
create mode 100644 C#核心/Lesson3_封装-成员方法练习/Lesson3_封装-成员方法练习.csproj
create mode 100644 C#核心/Lesson3_封装-成员方法练习/Program.cs
create mode 100644 C#核心/Lesson4_封装-构造函数和析构函数/Lesson4_封装-构造函数和析构函数.csproj
create mode 100644 C#核心/Lesson4_封装-构造函数和析构函数/Program.cs
create mode 100644 C#核心/Lesson4_封装-构造函数和析构函数练习/Lesson4_封装-构造函数和析构函数练习.csproj
create mode 100644 C#核心/Lesson4_封装-构造函数和析构函数练习/Program.cs
create mode 100644 C#核心/Lesson5_封装-成员属性/Lesson5_封装-成员属性.csproj
create mode 100644 C#核心/Lesson5_封装-成员属性/Program.cs
create mode 100644 C#核心/Lesson5_封装-成员属性练习/Lesson5_封装-成员属性练习.csproj
create mode 100644 C#核心/Lesson5_封装-成员属性练习/Program.cs
create mode 100644 C#核心/Lesson6_封装-索引器/Lesson6_封装-索引器.csproj
create mode 100644 C#核心/Lesson6_封装-索引器/Program.cs
create mode 100644 C#核心/Lesson6_封装-索引器练习/Lesson6_封装-索引器练习.csproj
create mode 100644 C#核心/Lesson6_封装-索引器练习/Program.cs
create mode 100644 C#核心/Lesson7_静态成员/Lesson7_封装-静态成员.csproj
create mode 100644 C#核心/Lesson7_静态成员/Program.cs
create mode 100644 C#核心/Lesson7_静态成员练习/Lesson7_封装-静态成员练习.csproj
create mode 100644 C#核心/Lesson7_静态成员练习/Program.cs
create mode 100644 C#核心/Lesson8_封装-静态类和静态构造函数/Lesson8_封装-静态类和静态构造函数.csproj
create mode 100644 C#核心/Lesson8_封装-静态类和静态构造函数/Program.cs
create mode 100644 C#核心/Lesson8_封装-静态类和静态构造函数练习/Lesson8_封装-静态类和静态构造函数练习.csproj
create mode 100644 C#核心/Lesson8_封装-静态类和静态构造函数练习/Program.cs
create mode 100644 C#核心/Lesson9_封装-拓展方法/Lesson9_封装-拓展方法.csproj
create mode 100644 C#核心/Lesson9_封装-拓展方法/Program.cs
create mode 100644 C#核心/Lesson9_封装-拓展方法练习/Lesson9_封装-拓展方法练习.csproj
create mode 100644 C#核心/Lesson9_封装-拓展方法练习/Program.cs
diff --git a/C#入门/C#入门.sln b/C#入门/C#入门.sln
new file mode 100644
index 0000000..8dbaaee
--- /dev/null
+++ b/C#入门/C#入门.sln
@@ -0,0 +1,211 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36203.30
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test1", "test1\test1.csproj", "{B5D2D87D-A962-4B4D-8D55-913F4B5D2467}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson1注释和console", "Lesson1\Lesson1注释和console.csproj", "{38D8CC7A-769C-4DE9-9835-54916128D614}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson2变量", "Lesson2变量\Lesson2变量.csproj", "{2E255F6C-89D2-4ECE-AC3F-4903A5D23765}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson2变量练习", "Lesson2变量练习\Lesson2变量练习.csproj", "{6BDC7E93-4AE2-4FD5-BD04-65720EDF0897}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson4变量的命名规则", "Lesson4变量的命名规则\Lesson4变量的命名规则.csproj", "{12B6A100-ABDE-40E8-B6F0-6FA53A805D9F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson5常量", "Lesson5常量\Lesson5常量.csproj", "{29321A63-B872-4C19-B9B2-AEBD90D21697}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson6转义字符", "Lesson6转义字符\Lesson6转义字符.csproj", "{536E2B30-EA7F-4D2F-AE45-B518B988253D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson7转义字符练习", "Lesson7转义字符练习\Lesson7转义字符练习.csproj", "{2925D024-47CC-4632-9CCE-DB7C2EE597CA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson7隐式转换_类型转换", "Lesson7隐式转换_类型转换\Lesson7隐式转换_类型转换.csproj", "{D47510F0-704D-4BB6-B814-4E7C5FA7F6D4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson8_显式转换", "Lesson8_显示转换\Lesson8_显式转换.csproj", "{DE655809-4BE0-46CE-A6AF-576B2AD80AB3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson8_显式转换练习", "Lesson8_显式转换联系\Lesson8_显式转换练习.csproj", "{C3B313DE-D643-42EE-BF8B-0197CBE0096B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson9_异常捕获", "Lesson9_异常捕获\Lesson9_异常捕获.csproj", "{96CB3658-80EE-4F20-9A1B-79D43C25DEDF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson9_捕获异常练习", "Lesson9_捕获异常联系\Lesson9_捕获异常练习.csproj", "{2B9B9029-A2B0-4EAF-8C3D-1840C23209C3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson10_算数运算符", "Lesson10_算数运算符\Lesson10_算数运算符.csproj", "{29A255F2-FFD0-4749-889A-C473BD8B1A01}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson10_算数运算符练习", "Lesson10_算数运算符练习\Lesson10_算数运算符练习.csproj", "{31DA648B-6D43-491D-8F74-A88095D778E1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson11_字符串拼接", "Lesson11_字符串拼接\Lesson11_字符串拼接.csproj", "{90AE5DB8-797B-4D1D-B9C8-931B9CB031CC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson11_字符串拼接练习", "Lesson11_字符串拼接练习\Lesson11_字符串拼接练习.csproj", "{390F2AAE-DADB-4054-B168-C4060195924F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson12_条件运算符", "Lesson12_条件运算符\Lesson12_条件运算符.csproj", "{C09FCC0C-79AC-4B56-8AE1-9914E2D9E2B2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson12_条件运算符练习", "Lesson12_条件运算符练习\Lesson12_条件运算符练习.csproj", "{B9E82214-EFF4-4060-998D-6A2FBB1BD09C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson13_ 逻辑运算符", "Lesson13_ 逻辑运算符\Lesson13_ 逻辑运算符.csproj", "{8C3FDC09-CC22-460A-AB0C-E25BD103C7CF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson13_逻辑运算符练习", "Lesson13_逻辑运算符练习\Lesson13_逻辑运算符练习.csproj", "{8D709A42-B8AA-4427-91DE-C9959F93F1A6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson14_位运算", "Lesson14_位运算\Lesson14_位运算.csproj", "{0FC71AB1-4975-41ED-8DDA-6743C6622614}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson14_位运算练习", "Lesson14_位运算练习\Lesson14_位运算练习.csproj", "{563D0FEB-699D-4B22-8187-07A53891FF78}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson15_三目运算符", "Lesson15_三目运算符\Lesson15_三目运算符.csproj", "{B33DAB08-87FA-4EC1-A78E-0E38D9021CA5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson15_三目运算符练习", "Lesson15_三目运算符练习\Lesson15_三目运算符练习.csproj", "{5A54CA20-4B7A-48D5-B975-16BD8A7529BC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson16_条件分支语句if", "Lesson16_if语句\Lesson16_条件分支语句if.csproj", "{E62F1255-E9C2-4738-B365-25BF5F6C6A1D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson16_条件分支语句if练习", "Lesson16_if语句练习\Lesson16_条件分支语句if练习.csproj", "{78484B21-A82F-4976-833B-5FF3D1B9C500}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson17_条件分支语句Switch", "Lesson17_条件分支语句Switch\Lesson17_条件分支语句Switch.csproj", "{F665FA1A-4EB9-48D8-BB93-3BDF9877362D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson17_条件分支语句Switch练习", "Lesson17_条件分支语句Switch练习\Lesson17_条件分支语句Switch练习.csproj", "{4C056E34-110B-442B-8F90-6C2B212CFA09}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson18_循环语句while", "Lesson18_循环语句while\Lesson18_循环语句while.csproj", "{C69CBFA5-EACB-4E07-9E10-FDA4D5F80166}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson19_循环语句dowhile", "Lesson19_循环语句dowhile\Lesson19_循环语句dowhile.csproj", "{16573E5F-7BC5-4BEF-9DFB-7A1012C0BD8B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson20_循环语句for", "Lesson19_循环语句for\Lesson20_循环语句for.csproj", "{D41F92B9-051D-4FF8-8AC0-9454A44FA31D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B5D2D87D-A962-4B4D-8D55-913F4B5D2467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B5D2D87D-A962-4B4D-8D55-913F4B5D2467}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B5D2D87D-A962-4B4D-8D55-913F4B5D2467}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B5D2D87D-A962-4B4D-8D55-913F4B5D2467}.Release|Any CPU.Build.0 = Release|Any CPU
+ {38D8CC7A-769C-4DE9-9835-54916128D614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {38D8CC7A-769C-4DE9-9835-54916128D614}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {38D8CC7A-769C-4DE9-9835-54916128D614}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {38D8CC7A-769C-4DE9-9835-54916128D614}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2E255F6C-89D2-4ECE-AC3F-4903A5D23765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2E255F6C-89D2-4ECE-AC3F-4903A5D23765}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2E255F6C-89D2-4ECE-AC3F-4903A5D23765}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2E255F6C-89D2-4ECE-AC3F-4903A5D23765}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6BDC7E93-4AE2-4FD5-BD04-65720EDF0897}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6BDC7E93-4AE2-4FD5-BD04-65720EDF0897}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6BDC7E93-4AE2-4FD5-BD04-65720EDF0897}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6BDC7E93-4AE2-4FD5-BD04-65720EDF0897}.Release|Any CPU.Build.0 = Release|Any CPU
+ {12B6A100-ABDE-40E8-B6F0-6FA53A805D9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {12B6A100-ABDE-40E8-B6F0-6FA53A805D9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {12B6A100-ABDE-40E8-B6F0-6FA53A805D9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {12B6A100-ABDE-40E8-B6F0-6FA53A805D9F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {29321A63-B872-4C19-B9B2-AEBD90D21697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {29321A63-B872-4C19-B9B2-AEBD90D21697}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {29321A63-B872-4C19-B9B2-AEBD90D21697}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {29321A63-B872-4C19-B9B2-AEBD90D21697}.Release|Any CPU.Build.0 = Release|Any CPU
+ {536E2B30-EA7F-4D2F-AE45-B518B988253D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {536E2B30-EA7F-4D2F-AE45-B518B988253D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {536E2B30-EA7F-4D2F-AE45-B518B988253D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {536E2B30-EA7F-4D2F-AE45-B518B988253D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2925D024-47CC-4632-9CCE-DB7C2EE597CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2925D024-47CC-4632-9CCE-DB7C2EE597CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2925D024-47CC-4632-9CCE-DB7C2EE597CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2925D024-47CC-4632-9CCE-DB7C2EE597CA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D47510F0-704D-4BB6-B814-4E7C5FA7F6D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D47510F0-704D-4BB6-B814-4E7C5FA7F6D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D47510F0-704D-4BB6-B814-4E7C5FA7F6D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D47510F0-704D-4BB6-B814-4E7C5FA7F6D4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE655809-4BE0-46CE-A6AF-576B2AD80AB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DE655809-4BE0-46CE-A6AF-576B2AD80AB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE655809-4BE0-46CE-A6AF-576B2AD80AB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DE655809-4BE0-46CE-A6AF-576B2AD80AB3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C3B313DE-D643-42EE-BF8B-0197CBE0096B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C3B313DE-D643-42EE-BF8B-0197CBE0096B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C3B313DE-D643-42EE-BF8B-0197CBE0096B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C3B313DE-D643-42EE-BF8B-0197CBE0096B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {96CB3658-80EE-4F20-9A1B-79D43C25DEDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {96CB3658-80EE-4F20-9A1B-79D43C25DEDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {96CB3658-80EE-4F20-9A1B-79D43C25DEDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {96CB3658-80EE-4F20-9A1B-79D43C25DEDF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2B9B9029-A2B0-4EAF-8C3D-1840C23209C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2B9B9029-A2B0-4EAF-8C3D-1840C23209C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2B9B9029-A2B0-4EAF-8C3D-1840C23209C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2B9B9029-A2B0-4EAF-8C3D-1840C23209C3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {29A255F2-FFD0-4749-889A-C473BD8B1A01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {29A255F2-FFD0-4749-889A-C473BD8B1A01}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {29A255F2-FFD0-4749-889A-C473BD8B1A01}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {29A255F2-FFD0-4749-889A-C473BD8B1A01}.Release|Any CPU.Build.0 = Release|Any CPU
+ {31DA648B-6D43-491D-8F74-A88095D778E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {31DA648B-6D43-491D-8F74-A88095D778E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {31DA648B-6D43-491D-8F74-A88095D778E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {31DA648B-6D43-491D-8F74-A88095D778E1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {90AE5DB8-797B-4D1D-B9C8-931B9CB031CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {90AE5DB8-797B-4D1D-B9C8-931B9CB031CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {90AE5DB8-797B-4D1D-B9C8-931B9CB031CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {90AE5DB8-797B-4D1D-B9C8-931B9CB031CC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {390F2AAE-DADB-4054-B168-C4060195924F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {390F2AAE-DADB-4054-B168-C4060195924F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {390F2AAE-DADB-4054-B168-C4060195924F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {390F2AAE-DADB-4054-B168-C4060195924F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C09FCC0C-79AC-4B56-8AE1-9914E2D9E2B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C09FCC0C-79AC-4B56-8AE1-9914E2D9E2B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C09FCC0C-79AC-4B56-8AE1-9914E2D9E2B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C09FCC0C-79AC-4B56-8AE1-9914E2D9E2B2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B9E82214-EFF4-4060-998D-6A2FBB1BD09C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B9E82214-EFF4-4060-998D-6A2FBB1BD09C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B9E82214-EFF4-4060-998D-6A2FBB1BD09C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B9E82214-EFF4-4060-998D-6A2FBB1BD09C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8C3FDC09-CC22-460A-AB0C-E25BD103C7CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8C3FDC09-CC22-460A-AB0C-E25BD103C7CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8C3FDC09-CC22-460A-AB0C-E25BD103C7CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8C3FDC09-CC22-460A-AB0C-E25BD103C7CF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8D709A42-B8AA-4427-91DE-C9959F93F1A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8D709A42-B8AA-4427-91DE-C9959F93F1A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8D709A42-B8AA-4427-91DE-C9959F93F1A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8D709A42-B8AA-4427-91DE-C9959F93F1A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0FC71AB1-4975-41ED-8DDA-6743C6622614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0FC71AB1-4975-41ED-8DDA-6743C6622614}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0FC71AB1-4975-41ED-8DDA-6743C6622614}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0FC71AB1-4975-41ED-8DDA-6743C6622614}.Release|Any CPU.Build.0 = Release|Any CPU
+ {563D0FEB-699D-4B22-8187-07A53891FF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {563D0FEB-699D-4B22-8187-07A53891FF78}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {563D0FEB-699D-4B22-8187-07A53891FF78}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {563D0FEB-699D-4B22-8187-07A53891FF78}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B33DAB08-87FA-4EC1-A78E-0E38D9021CA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B33DAB08-87FA-4EC1-A78E-0E38D9021CA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B33DAB08-87FA-4EC1-A78E-0E38D9021CA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B33DAB08-87FA-4EC1-A78E-0E38D9021CA5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5A54CA20-4B7A-48D5-B975-16BD8A7529BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5A54CA20-4B7A-48D5-B975-16BD8A7529BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5A54CA20-4B7A-48D5-B975-16BD8A7529BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5A54CA20-4B7A-48D5-B975-16BD8A7529BC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E62F1255-E9C2-4738-B365-25BF5F6C6A1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E62F1255-E9C2-4738-B365-25BF5F6C6A1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E62F1255-E9C2-4738-B365-25BF5F6C6A1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E62F1255-E9C2-4738-B365-25BF5F6C6A1D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {78484B21-A82F-4976-833B-5FF3D1B9C500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {78484B21-A82F-4976-833B-5FF3D1B9C500}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {78484B21-A82F-4976-833B-5FF3D1B9C500}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {78484B21-A82F-4976-833B-5FF3D1B9C500}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F665FA1A-4EB9-48D8-BB93-3BDF9877362D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F665FA1A-4EB9-48D8-BB93-3BDF9877362D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F665FA1A-4EB9-48D8-BB93-3BDF9877362D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F665FA1A-4EB9-48D8-BB93-3BDF9877362D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4C056E34-110B-442B-8F90-6C2B212CFA09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4C056E34-110B-442B-8F90-6C2B212CFA09}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4C056E34-110B-442B-8F90-6C2B212CFA09}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4C056E34-110B-442B-8F90-6C2B212CFA09}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C69CBFA5-EACB-4E07-9E10-FDA4D5F80166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C69CBFA5-EACB-4E07-9E10-FDA4D5F80166}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C69CBFA5-EACB-4E07-9E10-FDA4D5F80166}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C69CBFA5-EACB-4E07-9E10-FDA4D5F80166}.Release|Any CPU.Build.0 = Release|Any CPU
+ {16573E5F-7BC5-4BEF-9DFB-7A1012C0BD8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {16573E5F-7BC5-4BEF-9DFB-7A1012C0BD8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {16573E5F-7BC5-4BEF-9DFB-7A1012C0BD8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {16573E5F-7BC5-4BEF-9DFB-7A1012C0BD8B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D41F92B9-051D-4FF8-8AC0-9454A44FA31D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D41F92B9-051D-4FF8-8AC0-9454A44FA31D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D41F92B9-051D-4FF8-8AC0-9454A44FA31D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D41F92B9-051D-4FF8-8AC0-9454A44FA31D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {DA94A9F6-4704-4633-BFDB-26B03F3689FA}
+ EndGlobalSection
+EndGlobal
diff --git a/C#入门/Csharp入门.sln b/C#入门/Csharp入门.sln
deleted file mode 100644
index abf3241..0000000
--- a/C#入门/Csharp入门.sln
+++ /dev/null
@@ -1,43 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.14.36202.13 d17.14
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test1", "test1\test1.csproj", "{431A94A0-24B2-497E-A1FE-693FA2EF350F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson1注释&输入输出", "lesson1\Lesson1注释&输入输出.csproj", "{C9D85F7A-86E5-4034-AA0B-F469E441F9C5}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson1练习题", "Lession1练习题\Lesson1练习题.csproj", "{D965940D-E758-4A7C-977A-74E5793C593B}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson2变量", "Lesson2变量\Lesson2变量.csproj", "{21CE6A7D-CC82-4F41-A28F-54D2E535FB3F}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {431A94A0-24B2-497E-A1FE-693FA2EF350F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {431A94A0-24B2-497E-A1FE-693FA2EF350F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {431A94A0-24B2-497E-A1FE-693FA2EF350F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {431A94A0-24B2-497E-A1FE-693FA2EF350F}.Release|Any CPU.Build.0 = Release|Any CPU
- {C9D85F7A-86E5-4034-AA0B-F469E441F9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C9D85F7A-86E5-4034-AA0B-F469E441F9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C9D85F7A-86E5-4034-AA0B-F469E441F9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C9D85F7A-86E5-4034-AA0B-F469E441F9C5}.Release|Any CPU.Build.0 = Release|Any CPU
- {D965940D-E758-4A7C-977A-74E5793C593B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D965940D-E758-4A7C-977A-74E5793C593B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D965940D-E758-4A7C-977A-74E5793C593B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D965940D-E758-4A7C-977A-74E5793C593B}.Release|Any CPU.Build.0 = Release|Any CPU
- {21CE6A7D-CC82-4F41-A28F-54D2E535FB3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {21CE6A7D-CC82-4F41-A28F-54D2E535FB3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {21CE6A7D-CC82-4F41-A28F-54D2E535FB3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {21CE6A7D-CC82-4F41-A28F-54D2E535FB3F}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {972D1D6C-AC89-49B8-9AE0-EB671A0842D5}
- EndGlobalSection
-EndGlobal
diff --git a/C#入门/Lesson10_算数运算符/Lesson10_算数运算符.csproj b/C#入门/Lesson10_算数运算符/Lesson10_算数运算符.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson10_算数运算符/Lesson10_算数运算符.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson10_算数运算符/Program.cs b/C#入门/Lesson10_算数运算符/Program.cs
new file mode 100644
index 0000000..2c08d62
--- /dev/null
+++ b/C#入门/Lesson10_算数运算符/Program.cs
@@ -0,0 +1,140 @@
+using System;
+namespace Lesson10
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("算术运算符");
+ //算数运算符 是用于 数值类型变量计算的运算符
+ //他返回的结果是数值
+
+ #region 赋值运算符
+ // = 赋值运算符
+ // 关键知识点:
+ // 先看右侧 再看左侧 把右侧的值赋给左侧的变量
+
+ string myName = "HK";// 先看右侧 "HK" 再看左侧 myName 把 "HK" 赋值给 myName
+ int myAge = 18; // 先看右侧 18 再看左侧 myAge 把 18 赋值给 myAge
+ float myHeight = 1.75f; // 先看右侧 1.75f 再看左侧 myHeight 把 1.75f 赋值给 myHeight
+ #endregion
+
+ #region 算术运算符
+
+ #region +加号运算符
+ // 用自己计算 先算右侧结果 再赋值给左侧变量
+ int i = 1;
+ i = i + 2;//先算右侧 i + 2 = 3 再赋值给左侧 i
+ Console.WriteLine("i = " + i); // 输出 i = 3
+
+ //连续运算 先算右侧结果 再赋值给左侧变量
+ i = i + 2 + 3; //先算右侧 i + 2 + 3 = 8 再赋值给左侧 i
+ Console.WriteLine("i = " + i); // 输出 i = 8
+
+ //初始化时就运算 先算右侧结果 再赋值给左侧变量
+ int j = 1 + 2 + 3; //先算右侧 1 + 2 + 3 = 6 再赋值给左侧 j
+ Console.WriteLine("j = " + j); // 输出 j = 6
+ #endregion
+
+ #region -减号运算符
+ // 同加法
+ #endregion
+
+ #region *乘号运算符
+ // 乘法运算符 * 用于两个数相乘
+ int k = 2 * 3; //先算右侧 2 * 3 = 6 再赋值给左侧 k
+ Console.WriteLine("k = " + k); // 输出 k = 6
+ // 乘法也可以连续运算
+ k = k * 2 * 3; //先算右侧 k * 2 * 3 = 36 再赋值给左侧 k
+ Console.WriteLine("k = " + k); // 输出 k = 36
+ #endregion
+
+ #region /除号运算符
+ // 除法运算符 / 用于两个数相除
+ int m = 6 / 2; //先算右侧 6 / 2 = 3 再赋值给左侧 m
+ Console.WriteLine("m = " + m); // 输出 m = 3
+ // 除法也可以连续运算
+ m = m / 2 / 3; //先算右侧 m / 2 / 3 = 0 再赋值给左侧 m
+ Console.WriteLine("m = " + m); // 输出 m = 0
+ // 注意:除法运算如果除数为0,会抛出异常
+ try
+ {
+ int n = 6 / 0; //会抛出异常
+ }
+ catch (DivideByZeroException ex)
+ {
+ Console.WriteLine("除数不能为0!" + ex.Message);
+ }
+ #endregion
+
+ #region %取余运算符
+ // 取余运算符 % 用于两个数相除后,返回余数
+ int o = 7 % 3; //先算右侧 7 % 3 = 1 再赋值给左侧 o
+ Console.WriteLine("o = " + o); // 输出 o = 1
+ o = o / 3;
+ Console.WriteLine("o = " + o); // 输出 o = 0
+ // 注意:取余运算如果除数为0,会抛出异常
+ o = o / 3;
+ try
+ {
+ int p = 7 % 0; //会抛出异常
+ }
+ catch (DivideByZeroException ex)
+ {
+ Console.WriteLine("除数不能为0!" + ex.Message);
+ }
+ #endregion
+
+
+
+ #endregion
+
+ #region 算数运算符的 优先级
+ // 乘除取余运算符优先级高于加减运算符
+
+ // 先算乘除取余运算符 再算加减运算符
+ int a = 1 + 2 * 3 / 2 + 1;//先算右侧 2 * 3 = 6 再算 6 / 2 = 3 再算 1 + 3 + 1 = 5
+ Console.WriteLine(a);
+
+ //括号可以改变运算顺序
+ int b = (1 + 2) * 3 / 2 + 1; //先算右侧 (1 + 2) = 3 再算 3 * 3 = 9 再算 9 / 2 = 4.5 再算 4.5 + 1 = 5.5
+ Console.WriteLine(b);
+ //注意:括号内的运算优先级最高
+
+ //多组括号 可以嵌套运算 先算最内层括号
+ int c = (1 + (2 * 3)) / 2 + 1; //先算右侧 (2 * 3) = 6 再算 (1 + 6) = 7 再算 7 / 2 = 3.5 再算 3.5 + 1 = 4.5
+ Console.WriteLine(c);
+ #endregion
+
+ #region 算数运算符的 复合运算符号
+ // 复合运算符号 是对算数运算符的简化写法
+ // += 复合加法运算符
+ i += 2; //等价于 i = i + 2; 先算右侧 i + 2 = 10 再赋值给左侧 i
+ // -= 复合减法运算符
+ i -= 2; //等价于 i = i - 2; 先算右侧 i - 2 = 8 再赋值给左侧 i
+ // *= 复合乘法运算符
+ i *= 2; //等价于 i = i * 2; 先算右侧 i * 2 = 16 再赋值给左侧 i
+ // /= 复合除法运算符
+ i /= 2; //等价于 i = i / 2; 先算右侧 i / 2 = 8 再赋值给左侧 i
+ // %= 复合取余运算符
+ i %= 2;//等价于 i = i % 2; 先算右侧 i % 2 = 0 再赋值给左侧 i
+ #endregion
+
+ #region 算数运算符的 自增减
+ // 自增自减运算符 是对变量的值进行加1或减1的运算符
+ i = i + 1;
+ i += 1;
+ i++;
+ ++i;
+ //以上四种写法是等价的
+
+ //但是也有区别
+ i++;//表示的意思是先使用 i 的值,然后再加1
+ ++i;//表示的意思是先加1,然后再使用 i 的值
+
+ //自减运算符同理
+ #endregion
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson10_算数运算符练习/Lesson10_算数运算符练习.csproj b/C#入门/Lesson10_算数运算符练习/Lesson10_算数运算符练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson10_算数运算符练习/Lesson10_算数运算符练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson10_算数运算符练习/Program.cs b/C#入门/Lesson10_算数运算符练习/Program.cs
new file mode 100644
index 0000000..f477756
--- /dev/null
+++ b/C#入门/Lesson10_算数运算符练习/Program.cs
@@ -0,0 +1,55 @@
+using System;
+namespace Lesson10
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 年龄
+ int myAge = 18;
+ myAge += 10;
+ Console.WriteLine("十年后我的年龄是:" + myAge);
+ #endregion
+
+
+ #region 圆的面积
+ const float PI = 3.1415926f;
+ int radius = 5;
+ float area = PI * radius * radius;
+ float circumference = 2f * PI * radius;
+ Console.WriteLine("半径为" + radius + "的圆的面积是:" + area + "周长是:" + circumference);
+ #endregion
+
+ #region 计算成绩
+ int score1 = 80;
+ int score2 = 90;
+ int score3 = 92;
+ int totalScore = score1 + score2 + score3;
+ float avgScore = totalScore / 3.0f;
+ Console.WriteLine("你的总成绩为:" + totalScore);
+ Console.WriteLine("你的平均分为:" + avgScore);
+ #endregion
+
+ #region 交换变量值
+ int a = 99;
+ int b = 87;
+ int temp;
+ temp = a;
+ a = b;
+ b = temp;
+ Console.WriteLine($"交换后A的值为:{a}B的值为:{b}");
+ #endregion
+
+ #region 时间转换
+ int second = 987652;
+ int hour, minute, day;
+ day = second / 86400; // 1天 = 86400秒
+ hour = (second - (day * 86400)) / 3600; // 1小时 = 3600秒
+ minute = (second - (day * 86400 + hour * 3600)) / 60; // 1分钟 = 60秒
+ second = second - (day * 86400 + hour * 3600 + minute * 60);
+ Console.WriteLine($"转换后的时间为{day}天{hour}小时{minute}分钟{second}秒");
+ #endregion
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson11_字符串拼接/Lesson11_字符串拼接.csproj b/C#入门/Lesson11_字符串拼接/Lesson11_字符串拼接.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson11_字符串拼接/Lesson11_字符串拼接.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson11_字符串拼接/Program.cs b/C#入门/Lesson11_字符串拼接/Program.cs
new file mode 100644
index 0000000..7089fe3
--- /dev/null
+++ b/C#入门/Lesson11_字符串拼接/Program.cs
@@ -0,0 +1,68 @@
+using System;
+namespace lesson11
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("字符串拼接");
+ Console.WriteLine();
+
+ #region 知识点一字符串拼接方式1
+ //算数运算符只是用来数值运算
+ //而string不能来做数值运算
+ //但是可以用来做字符串拼接
+ Console.WriteLine("拼接方式一加号拼接:");
+ //字符串拼接的方式1:使用加号运算符
+ string str = "123";
+ str = str + "456"; //字符串拼接
+ Console.WriteLine(str);
+
+ str = str + 1;//1虽然没有加双引号,但它会被自动转换为字符串
+ Console.WriteLine(str);
+
+ //如果需要加上数值,可以先转换为数值类型,运算完成后再转换为字符串
+ str = (int.Parse(str) + Convert.ToInt32("1")).ToString();
+ Console.WriteLine(str);
+
+ //复合运算符也可以用来拼接字符串
+ str = "123";
+ str += "456" + 7 + true;
+ Console.WriteLine(str);
+
+ //但是要注意加号运算符拼接时,后面全是数值类型
+ str = "123";
+ str += 4 + 5;//这里因为运算规则,会先看右边全是数值类型,所以是以数值类型先运算完后再转换为字符串拼接
+ Console.WriteLine(str);
+ str = "123";
+ str += 1 + 2 + "" + 3 + 4;//这里会先运算1+2的结果再把3和4当作字符串拼接上去
+ Console.WriteLine(str);
+
+ //如果后方只拼接数值类型,但又不想被当作数值类型运算,可以直接套双引号或加空双引号""来避免这种问题
+ str = "123";
+ str += "" + 4 + 5;
+ Console.WriteLine(str);
+
+ Console.WriteLine();
+ #endregion
+
+ #region 知识点二字符串拼接方式2
+ //固定语法
+ //string.Format("待拼接的字符串", 内容1, 内容2, ...);
+ //拼接内容中的固定规则
+ //想要被拼接的内容用占位符{}来表示
+ //eg: "拼接内容{0},内容{1},内容{2}"
+ string str2 = string.Format("我是{0},今年{1}岁,我想要{2}", "ZJ", 18, "天天开心");
+ Console.WriteLine(str2);
+
+ Console.WriteLine();
+ #endregion
+
+ #region 知识点三控制台打印
+ //和方法二类似
+ Console.WriteLine("A{0},B{1},C{2}",1,2,3);
+ #endregion
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson11_字符串拼接练习/Lesson11_字符串拼接练习.csproj b/C#入门/Lesson11_字符串拼接练习/Lesson11_字符串拼接练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson11_字符串拼接练习/Lesson11_字符串拼接练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson11_字符串拼接练习/Program.cs b/C#入门/Lesson11_字符串拼接练习/Program.cs
new file mode 100644
index 0000000..291f9dd
--- /dev/null
+++ b/C#入门/Lesson11_字符串拼接练习/Program.cs
@@ -0,0 +1,35 @@
+using System;
+namespace Lessson11_exercise
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ string customerName = "张三";
+ Console.WriteLine("你好,{0}",customerName);
+ Console.WriteLine();
+
+ string customerName2 = "李四";
+ int customerAge = 25;
+ Console.WriteLine("{0}今年{1}岁了\n", customerName2,customerAge);
+
+ string name = "小明";
+ int age = 20;
+ string email = "123@gmail.com";
+ string address = "北京市朝阳区某街道某小区";
+ string phone = "12345678901";
+ Console.WriteLine("姓名:{0}\n年龄:{1}\n邮箱:{2}\n地址:{3}\n电话:{4}\n", name, age, email, address, phone);
+
+ string username;
+ int age1;
+ string classes;
+ Console.WriteLine("请输入你的用户名:");
+ username = Console.ReadLine();
+ Console.WriteLine("请输入你的年龄:");
+ age1 = Convert.ToInt32(Console.ReadLine());
+ Console.WriteLine("请输入你的班级:");
+ classes = Console.ReadLine();
+ Console.WriteLine("你是{0}\n你今年{1}岁了\n班级是{2}\n",username,age1,classes);
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson11_练习题/Lesson11_练习题.csproj b/C#入门/Lesson11_练习题/Lesson11_练习题.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson11_练习题/Lesson11_练习题.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson11_练习题/Program.cs b/C#入门/Lesson11_练习题/Program.cs
new file mode 100644
index 0000000..19df407
--- /dev/null
+++ b/C#入门/Lesson11_练习题/Program.cs
@@ -0,0 +1,23 @@
+using System;
+namespace lesson11
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 1
+ string customerName = "张三";
+ Console.WriteLine("你好"+customerName);
+
+ Console.WriteLine("你好{0}", customerName);
+
+ string str = string.Format("你好{0}", customerName);
+ Console.WriteLine(str);
+ #endregion
+
+ #region 2
+
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson12_条件运算符/Lesson12_条件运算符.csproj b/C#入门/Lesson12_条件运算符/Lesson12_条件运算符.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson12_条件运算符/Lesson12_条件运算符.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson12_条件运算符/Program.cs b/C#入门/Lesson12_条件运算符/Program.cs
new file mode 100644
index 0000000..b2c61ef
--- /dev/null
+++ b/C#入门/Lesson12_条件运算符/Program.cs
@@ -0,0 +1,88 @@
+using System;
+namespace lesson12_条件运算符
+{
+ class program
+ {
+ static void Main(String[] args)
+ {
+ #region 知识点一 条件运算符
+ //用于比较两个变量或常量
+ // 是否大于 >
+ // 是否小于 <
+ // 是否大于等于 >=
+ // 是否小于等于 <=
+ // 是否等于 ==
+ // 是否不等于 !=
+
+ // 条件运算符一定存在两边的内容
+ // 左边的内容 条件运算符 右边的内容
+ int a = 5;
+ int b = 10;
+
+ // a > b; 判断 a 是否大于 b
+ // 结果是一个布尔值 true 或 false
+
+ bool result = a > b; // 将结果赋值给变量
+ Console.WriteLine(result); // 输出结果
+ Console.WriteLine(a < b);
+ #endregion
+
+ #region 知识点二 各种应用写法
+ a = 5;
+ b = 10;
+ //变量和变量的比较
+ result = a > b; // false
+ //变量和常量的比较
+ result = a < 10;//true
+ result = b > 5;//true
+ //数值和数值的比较
+ result = 5 < 10; // true
+ result = 10 >= 5; // true
+ result = 5 != 10; // true
+ //计算结果比较(优先级知识点)
+ result = a+3 > b-2; // true
+
+ #endregion
+
+ #region 知识点三 不能进行范围比较
+ a = 5;
+ //判断是否在某个范围内
+ // 1 < a < 10; // 错误的写法,不能直接使用范围比较
+ // 需要使用逻辑运算符来实现范围比较
+ // 正确的写法是使用逻辑与运算符 && 来连接两个条件
+ result = a > 1 && a < 10; // true
+ #endregion
+
+ #region 知识点四 不同类型的比较
+ // 不同类型的比较会发生隐式转换
+ int i = 5;
+ float f = 1.2f;
+ double d = 12.4;
+ short s = 2;
+ byte by = 20;
+ uint ui = 222;
+
+ result = i > f; // true, int 和 float 比较,int 转换为 float
+ result = f < d; // true, float 和 double 比较,float 转换为 double
+ result = i < by; // true, int 和 byte 比较,byte 转换为 int
+ result = i < ui; // true, int 和 uint 比较,int 转换为 uint
+
+ //特殊类型 char string bool 只能和同类型进行 == 和 != 比较
+ string str = "123";
+ char fc = 'A';
+ bool bo = true;
+
+ result = str == "123"; // true, string 和 string 比较
+ result = str == "234"; // false, string 和 string 比较
+
+
+ //char不仅可以和 char 比较,还可以和 int 比较
+ char c = 'A';
+ result = c > 123; // true, char 和 int 比较,char 转换为 int
+ result = c > 'a'; // true, char 和 char 比较
+
+
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson12_条件运算符练习/Lesson12_条件运算符练习.csproj b/C#入门/Lesson12_条件运算符练习/Lesson12_条件运算符练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson12_条件运算符练习/Lesson12_条件运算符练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson12_条件运算符练习/Program.cs b/C#入门/Lesson12_条件运算符练习/Program.cs
new file mode 100644
index 0000000..82cca9d
--- /dev/null
+++ b/C#入门/Lesson12_条件运算符练习/Program.cs
@@ -0,0 +1,35 @@
+using System;
+namespace Lesson12_练习题
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 口算
+ //请回答一下问题:
+ //我的年龄(18)>你们的年龄(22)false
+ //兔子的速度(3m/s)<乌龟的速度(1m/s)false
+ //狗的重量(50kg)<兔子的重量(2kg)false
+ //我有钱(10元)==你有钱(10元)true
+ #endregion
+
+ #region 求打印结果
+ //bool b = true;
+ //console.WriteLine(b != true); false
+ //console.WriteLine(10==10); ture
+ //console.WriteLine(10 > 20); false
+ //console.WriteLine(10 <= 20); true
+ //console.WriteLine(10 <= 10); true
+ #endregion
+
+ #region 综合练习
+ //bool gameOver,startGame;
+ //int a = 10,b = 15;
+ //gameOver = a > (b - 5);
+ //startGame = gameOver == (b > (a + 5));
+ //console.WriteLine("stratGame = " + startGame);
+ //true
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson13_ 逻辑运算符/Lesson13_ 逻辑运算符.csproj b/C#入门/Lesson13_ 逻辑运算符/Lesson13_ 逻辑运算符.csproj
new file mode 100644
index 0000000..95e29e1
--- /dev/null
+++ b/C#入门/Lesson13_ 逻辑运算符/Lesson13_ 逻辑运算符.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson13__逻辑运算符
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson13_ 逻辑运算符/Program.cs b/C#入门/Lesson13_ 逻辑运算符/Program.cs
new file mode 100644
index 0000000..a8b36b2
--- /dev/null
+++ b/C#入门/Lesson13_ 逻辑运算符/Program.cs
@@ -0,0 +1,82 @@
+using System;
+namespace Lesson12_逻辑运算符
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点一 逻辑与
+ //符号&&
+ //规则:对两个bool值进行逻辑与运算,只有当两个值都为true时,结果才为true,否则为false。
+ bool result = true && false;
+ Console.WriteLine(result); // 输出: False
+ result = true && true;
+ Console.WriteLine(result); // 输出: True
+
+ //bool相关类型 bool变量 条件运算符
+ //逻辑运算符优先级 低于 条件运算符 和 关系运算符
+ result = 3 > 1 && 1 < 2;// 先计算关系运算符,再计算逻辑运算符
+ Console.WriteLine(result);// 输出: True
+
+ int i = 3;
+ result = i > 1 && i < 5; // 先计算关系运算符,再计算逻辑运算符
+ Console.WriteLine(result); // 输出: True
+ #endregion
+
+ #region 知识点二 逻辑或
+ //符号||
+ //规则:对两个bool值进行逻辑或运算,只要有一个值为true,结果就为true,否则为false。
+ result = true || false;
+ Console.WriteLine(result);// 输出: True
+ result = false || true;
+ Console.WriteLine(result);// 输出: True
+ result = true || true;
+ Console.WriteLine(result);// 输出: True
+ result = false || false;
+ Console.WriteLine(result);// 输出: False
+ #endregion
+
+ #region 知识点三 逻辑非
+ //符号!
+ //规则:对一个bool值进行取反,真变假,假变真
+ result = !true;
+ Console.WriteLine(result);// 输出:false
+ result = !false;
+ Console.WriteLine(result);// 输出:true
+ result = !!false;
+ Console.WriteLine(result);// 输出:false
+
+ //result = !3 > 2;
+ //逻辑非的优先级较高会直接报错必须要套括号
+ result = !(3 > 2);
+ Console.WriteLine(result);// 输出:false
+ #endregion
+
+ #region 知识点四 混合使用优先级
+ //规则 !(逻辑非)的优先级最高,&&(逻辑与)的优先级高于||(逻辑或)
+ //逻辑运算符优先级 低于 算术运算符 条件运算符
+
+ bool gameOver = false;
+ int hp = 100;
+ bool isDead = false;
+ bool isMustOver = true;
+
+ result = gameOver || hp < 0 && !isDead || isMustOver;
+ Console.WriteLine(result);//输出 True
+ #endregion
+
+ #region 知识点五 逻辑运算符短路规则
+ int i3 = 1;
+ //短路
+ result = i3 > 0 || ++i3 >= 1;//i3此时不会+1为2
+ Console.WriteLine(i3);
+ Console.WriteLine(result);//输出true
+ //在左边i3 > 0运算后,已经出现了boolean值,后面的表达式不会计算了
+ //概念:只要逻辑与 或者 逻辑或 左边已经满足了条件,后面的结果不会继续运算了
+ result = ++i3 >= 1 && i3 < 0;//i3此时会先进行运算
+ Console.WriteLine(i3);
+ Console.WriteLine(result);//输出false
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson13_逻辑运算符练习/Lesson13_逻辑运算符练习.csproj b/C#入门/Lesson13_逻辑运算符练习/Lesson13_逻辑运算符练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson13_逻辑运算符练习/Lesson13_逻辑运算符练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson13_逻辑运算符练习/Program.cs b/C#入门/Lesson13_逻辑运算符练习/Program.cs
new file mode 100644
index 0000000..dbe5090
--- /dev/null
+++ b/C#入门/Lesson13_逻辑运算符练习/Program.cs
@@ -0,0 +1,27 @@
+using System;
+namespace Lesson13
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 练习题一
+ //求打印结果
+ //Console.WriteLine(true || true); true
+ //Console.WriteLine(false || true); true
+ //Console.WriteLine(true && true); true
+ //Console.WriteLine(true && false); false
+ //Console.WriteLine(!true);false
+ #endregion
+
+ #region 练习题二
+ //求打印结果
+ bool gameOver;
+ bool isWin;
+ int health = 100;
+ gameOver = true;
+ isWin = false;
+ Console.WriteLine(gameOver || isWin && health > 0);//true
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson14_位运算/Lesson14_位运算.csproj b/C#入门/Lesson14_位运算/Lesson14_位运算.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson14_位运算/Lesson14_位运算.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson14_位运算/Program.cs b/C#入门/Lesson14_位运算/Program.cs
new file mode 100644
index 0000000..4f35231
--- /dev/null
+++ b/C#入门/Lesson14_位运算/Program.cs
@@ -0,0 +1,64 @@
+using System;
+namespace Lesson14
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ //位运算主要使用数值类型计算
+ //将数值类型转换为二进制形式进行计算
+ //位运算符包括:& | ^ ~ << >>
+
+ #region 知识点一 位与 &
+ // 规则 连接两个数值进行位与运算 将数值转为二进制
+ // 对位运算 有0则0
+ int a = 1;//001
+ int b = 5;//101
+ int c = a & b;
+ // 001 & 101 = 001
+ Console.WriteLine(c);//001 & 101 = 001
+ Console.WriteLine(10 & 5);//1010 & 0101 = 0000
+ Console.WriteLine(3 & 19);//00011 & 10011 = 00011
+ Console.WriteLine(19 & 3);//10011 & 00011 = 00011
+ Console.WriteLine(1 & 2);//01 & 10 = 00
+ //有点像是取最小的数,但不实际是这样
+ #endregion
+
+ #region 知识点二 位或 |
+ // 规则 连接两个数值进行位或运算 将数值转为二进制
+ // 对位运算 有1则1
+ Console.WriteLine(2 & 3);// 00010 & 00011 = 00011
+ Console.WriteLine(3 & 2);// 00011 & 00010 = 00011
+ Console.WriteLine(12 & 3);// 00001100 & 00000011 = 00000000
+ #endregion
+
+ #region 知识点三 位异或 ^
+ // 规则 连接两个数值进行位异或运算 将数值转为二进制
+ // 对位运算 相同为0 不同为1
+ Console.WriteLine(2 ^ 3);// 00010 ^ 00011 = 00001
+ Console.WriteLine(3 ^ 2);// 00011 ^ 00010 = 00001
+ Console.WriteLine(12 ^ 3);// 00001100 ^ 00000011 = 00001111
+ #endregion
+
+ #region 知识点四 位非 ~
+ // 规则 连接一个数值进行位非运算 将数值转为二进制
+ // 对位运算 0变1 1变0
+ Console.WriteLine(~2);// ~00010 = 11101 = -3
+ // 但是要注意,特定变量类型前面的位会补全例如int
+ int test = 10;
+ Console.WriteLine(~test);// ~00000000000000000000000000001010 = 11111111111111111111111111110101 = -11
+ #endregion
+
+ #region 知识点五 左移 << 和 右移 >>
+ // 规则 左移运算符将数值的二进制位向左移动指定的位数,右移运算符将数值的二进制位向右移动指定的位数
+ // 左移相当于乘以2的n次方 右移相当于除以2的n次方
+ a = 5;// 101
+ c = a << 5; // 5左移5位
+ Console.WriteLine(c);// 10100000 = 160
+ //右移同理
+ c = a >> 2; // 5右移2位
+ Console.WriteLine(c);// 00000101 >> 2 = 00000001 = 1
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson14_位运算练习/Lesson14_位运算练习.csproj b/C#入门/Lesson14_位运算练习/Lesson14_位运算练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson14_位运算练习/Lesson14_位运算练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson14_位运算练习/Program.cs b/C#入门/Lesson14_位运算练习/Program.cs
new file mode 100644
index 0000000..1dc5107
--- /dev/null
+++ b/C#入门/Lesson14_位运算练习/Program.cs
@@ -0,0 +1,31 @@
+using System;
+namespace lesson14
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 练习题一
+ // 35 << 4 和 66 >> 1 的结果是多少?
+ // 35 = 00100011
+ // 35 << 4 = 001000110000 = 560
+ Console.WriteLine(35 << 4);
+ // 66 = 01000010
+ // 66 >> 1 = 00100001 = 33
+ Console.WriteLine(66 >> 1);
+ #endregion
+
+ #region 练习题二
+ // 99 ^ 33 和 76 | 85 的结果是多少?
+ // 99 = 01100011
+ // 33 = 00100001
+ // 99 ^ 33 = 01000010 = 66
+ Console.WriteLine(99 ^ 33);
+ // 76 = 01001100
+ // 85 = 01010101
+ // 76 | 85 = 01011101 = 125
+ Console.WriteLine(76 | 85);
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson15_三目运算符/Lesson15_三目运算符.csproj b/C#入门/Lesson15_三目运算符/Lesson15_三目运算符.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson15_三目运算符/Lesson15_三目运算符.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson15_三目运算符/Program.cs b/C#入门/Lesson15_三目运算符/Program.cs
new file mode 100644
index 0000000..fd39ed5
--- /dev/null
+++ b/C#入门/Lesson15_三目运算符/Program.cs
@@ -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
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson15_三目运算符练习/Lesson15_三目运算符练习.csproj b/C#入门/Lesson15_三目运算符练习/Lesson15_三目运算符练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson15_三目运算符练习/Lesson15_三目运算符练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson15_三目运算符练习/Program.cs b/C#入门/Lesson15_三目运算符练习/Program.cs
new file mode 100644
index 0000000..5f795fb
--- /dev/null
+++ b/C#入门/Lesson15_三目运算符练习/Program.cs
@@ -0,0 +1,18 @@
+
+#region 练习题一
+//比较两个数的大小,求出最大的
+//int a = 10;
+//int b = 15;
+
+//string str = a > b ? "a大于b" : "b大于等于a";
+//Console.WriteLine(str); // 输出:b大于等于a
+
+Console.WriteLine("请输入两个数来比较大小");
+Console.WriteLine("请输入第一个数:");
+int a = int.Parse(Console.ReadLine());
+Console.WriteLine("请输入第二个数:");
+int b = int.Parse(Console.ReadLine());
+
+string result = a > b ? "第一个数大于第二个数" : "第二个数大于等于第一个数";
+Console.WriteLine(result);
+#endregion
\ No newline at end of file
diff --git a/C#入门/Lesson16_if语句/Lesson16_条件分支语句if.csproj b/C#入门/Lesson16_if语句/Lesson16_条件分支语句if.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson16_if语句/Lesson16_条件分支语句if.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson16_if语句/Program.cs b/C#入门/Lesson16_if语句/Program.cs
new file mode 100644
index 0000000..754f9c1
--- /dev/null
+++ b/C#入门/Lesson16_if语句/Program.cs
@@ -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
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson16_if语句练习/Program.cs b/C#入门/Lesson16_if语句练习/Program.cs
new file mode 100644
index 0000000..f37ab2a
--- /dev/null
+++ b/C#入门/Lesson16_if语句练习/Program.cs
@@ -0,0 +1,146 @@
+
+#region 练习题一
+//try
+//{
+// Console.Write("请输入你今天看教学的时长:");
+// int time = Convert.ToInt16(console.readline());
+// if (time >= 60)
+// {
+// Console.WriteLine("今天看视频花了{0}分钟,看来你离成功又近了一步!", time);
+// }
+// else Console.WriteLine("请继续努力");
+//}
+//catch
+//{
+// Console.WriteLine("输入格式有误请重新重试");
+//}
+#endregion
+
+#region 练习题二
+//try
+//{
+// int yuWen, shuXue, yingYu;
+// Console.Write("请输入你的语文成绩:");
+// yuWen = Convert.ToInt16(Console.ReadLine());
+// Console.Write("请输入你的数学成绩:");
+// shuXue = Convert.ToInt16(Console.ReadLine());
+// Console.Write("请输入你的英语成绩:");
+// yingYu = Convert.ToInt16(Console.ReadLine());
+
+// if (yuWen >= 70 && shuXue >= 80 && yingYu >= 90)
+// {
+// Console.WriteLine("非常棒,请继续加油");
+// }
+// else if (yuWen >= 90 && (shuXue >= 70 || yingYu >= 70))
+// {
+// Console.WriteLine("非常棒,请继续加油");
+// }
+// else if (yuWen == 100 && shuXue == 100 && yingYu == 100)
+// {
+// Console.WriteLine("非常棒,请继续加油");
+// }
+// else Console.WriteLine("请你继续加油");
+//}
+//catch
+//{
+// Console.WriteLine("输入的格式有误");
+//}
+
+#endregion
+
+#region 练习题三
+//Console.Write("请输入你的成绩:");
+
+//try
+//{
+// int score = int.Parse(Console.ReadLine());
+// if (score >= 90)
+// {
+// Console.WriteLine("奖励一百");
+// }
+// else Console.WriteLine("一个月不准玩游戏");
+//}
+//catch
+//{
+// Console.WriteLine("输入有误");
+//}
+
+#endregion
+
+#region 练习题四
+//int a, b;
+//try
+//{
+// Console.WriteLine("请输入A的值:");
+// a = Convert.ToInt32(Console.ReadLine());
+// Console.WriteLine("请输入B的值:");
+// b = Convert.ToInt32(Console.ReadLine());
+// if (a+b >= 100)
+// {
+// Console.WriteLine(a);
+// }
+// else if (a%b==0 || b%a == 0)
+// {
+// Console.WriteLine(a);
+// }
+// else Console.WriteLine(b);
+//}
+//catch
+//{
+// Console.WriteLine("输入格式有误");
+//}
+#endregion
+
+#region 练习题五
+//try
+//{
+// Console.WriteLine("请输入一个数");
+// int num = int.Parse(Console.ReadLine());
+// if (num % 2==0)
+// {
+// Console.WriteLine("这是个偶数");
+// }
+// else Console.WriteLine("这是个奇数");
+//}
+//catch
+//{
+// Console.WriteLine("你输入的格式有误");
+//}
+#endregion
+
+#region 练习题六
+//int num1 = 1, num2 = 2, num3 = 0;
+//if (num1 >= num2 && num1 >= num3)
+//{
+// Console.WriteLine("num1:{0}",num1);
+//}
+//else if (num2 >= num1 && num2 >= num3)
+//{
+// Console.WriteLine("num2:{0}",num2);
+//}
+//else Console.WriteLine("num3:{0}", num3);
+#endregion
+
+#region 练习题七
+//Console.Write("请输入一个字符");
+//int num = Console.ReadKey().KeyChar;
+//Console.WriteLine();
+//if ('0' <= num && '9' >= num)
+//{
+// Console.WriteLine("你输入的是一个数字");
+//}
+//else
+//{
+// Console.WriteLine("这不是一个数字");
+//}
+#endregion
+
+#region 练习题八
+Console.WriteLine("太简单不做了");
+#endregion
+
+#region 练习题九
+#endregion
+
+#region 练习题十
+#endregion
\ No newline at end of file
diff --git a/C#入门/Lesson17_条件分支语句Switch/Lesson17_条件分支语句Switch.csproj b/C#入门/Lesson17_条件分支语句Switch/Lesson17_条件分支语句Switch.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson17_条件分支语句Switch/Lesson17_条件分支语句Switch.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson17_条件分支语句Switch/Program.cs b/C#入门/Lesson17_条件分支语句Switch/Program.cs
new file mode 100644
index 0000000..4604199
--- /dev/null
+++ b/C#入门/Lesson17_条件分支语句Switch/Program.cs
@@ -0,0 +1,114 @@
+using System;
+namespace Lesson17_条件分支语句Switch
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点一 作用
+ //让顺序的代码产生分支
+
+ #endregion
+
+ #region 知识点二 语法
+ //switch(变量)
+ //{
+ // case 常量1:
+ // //执行语句1
+ // break;
+ // case 常量2:
+ // //执行语句2
+ // break;
+ // default:
+ // //case条件都不满足执行默认语句
+ // break;
+ //}
+
+ //注意:常量只能是一个值,不能是条件/逻辑运算符
+
+ int a = 3;
+ switch (a)
+ {
+ case 1:
+ Console.WriteLine("a的值是1");
+ break;
+ case 2:
+ Console.WriteLine("a的值是2");
+ break;
+ case 3:
+ Console.WriteLine("a的值是3");
+ break;
+ default:
+ Console.WriteLine("没有满足的条件");
+ break;
+ }
+ //switch一般配合枚举使用
+
+ #endregion
+
+ #region 知识点三 default可省略
+ string str = "123";
+ switch (str)
+ {
+ case "321":
+ Console.WriteLine("值为1");
+ break;
+ case "213":
+ Console.WriteLine("值为123");
+ break;
+ //不写default,什么都不会运行
+ }
+ #endregion
+
+ #region 知识点四 可自定义常量
+ char c = 'A';
+ const char c2 = 'A';//常量必须const初始化,且不能修改
+ switch (c)
+ {
+ case c2:
+ Console.WriteLine("值为A");
+ break;
+ case 'B':
+ Console.WriteLine("值为B");
+ break;
+ default:
+ Console.WriteLine("没有满足的条件");
+ break;
+ }
+ #endregion
+
+ #region 贯穿
+ int aa = 1;
+ switch (aa)
+ {
+ case 1:
+ Console.WriteLine("aa的值是1");
+ goto case 2; //贯穿到case 2
+ case 2:
+ Console.WriteLine("aa的值是2");
+ break;
+ case 3:
+ Console.WriteLine("aa的值是3");
+ break;
+ default:
+ Console.WriteLine("没有满足的条件");
+ break;
+ }
+ //贯穿是指在一个case中没有使用break语句,直接跳转到下一个case
+ //注意:贯穿会导致后续的case也被执行,除非遇到break或default
+ switch (aa)
+ {
+ case 1://会直接进入case 2
+ case 2:
+ case 3:
+ case 4:
+ Console.WriteLine("这是一个数字");
+ break;
+ default:
+ Console.WriteLine("这是一个其他类型");
+ break;
+ }
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson17_条件分支语句Switch练习/Lesson17_条件分支语句Switch练习.csproj b/C#入门/Lesson17_条件分支语句Switch练习/Lesson17_条件分支语句Switch练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson17_条件分支语句Switch练习/Lesson17_条件分支语句Switch练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson17_条件分支语句Switch练习/Program.cs b/C#入门/Lesson17_条件分支语句Switch练习/Program.cs
new file mode 100644
index 0000000..a52869a
--- /dev/null
+++ b/C#入门/Lesson17_条件分支语句Switch练习/Program.cs
@@ -0,0 +1,135 @@
+using System;
+namespace Lesson17_条件分支语句Switch练习
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 练习题一
+ int salary = 4000;
+ string comment;
+ Console.WriteLine("请输入你的评价:");
+ try
+ {
+ comment = Console.ReadLine();
+ switch (comment)
+ {
+ case "很兴奋":
+ salary += 500;
+ break;
+ case "很充实":
+ break;
+ case "还好吧":
+ salary -= 300;
+ break;
+ case "难理解":
+ salary -= 500;
+ break;
+ case "很无聊":
+ salary -= 800;
+ break;
+ default:
+ Console.WriteLine("请你输入正确的评价");
+ break;
+ }
+ Console.WriteLine("唐老师的工资是{0}", salary);
+ }catch (Exception ex)
+ {
+ Console.WriteLine("发生异常:{0}", ex.Message);
+ }
+ #endregion
+
+ #region 练习题二
+ int money = 10;
+ int choice;
+ Console.WriteLine("菜单:\n1=中杯,¥5\n2=大杯,¥7\n3=超大杯,¥11\n请你选择需要购买的咖啡:");
+ try
+ {
+ choice = int.Parse(Console.ReadLine());
+ switch (choice)
+ {
+ case 1:
+ money -= 5;
+ if (money < 0)
+ {
+ Console.WriteLine("余额不足");
+ break;
+ }
+ Console.WriteLine("你买了中杯,还剩{0}元",money);
+ break;
+ case 2:
+ money -= 7;
+ if (money < 0)
+ {
+ Console.WriteLine("余额不足");
+ break;
+ }
+ Console.WriteLine("你买了大杯,还剩{0}元", money);
+ break;
+ case 3:
+ money -= 11;
+ if (money < 0)
+ {
+ Console.WriteLine("余额不足");
+ break;
+ }
+ Console.WriteLine("你买了超大杯,还剩{0}元", money);
+ break;
+ default:
+ Console.WriteLine("没有这个选项,请重新选择。");
+ break;
+ }
+
+ }catch (FormatException)
+ {
+ Console.WriteLine("输入格式错误,请输入数字。");
+ return;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("发生异常:{0}", ex.Message);
+ return;
+ }
+ #endregion
+
+ #region 练习题三
+
+ Console.WriteLine("请你输入你的考试成绩:");
+ try {
+ int score = int.Parse(Console.ReadLine());
+ switch (score)
+ {
+ case < 0:
+ Console.WriteLine("成绩不能为负数,请重新输入。");
+ break;
+ case <= 60:
+ Console.WriteLine("不及格");
+ break;
+ case <= 80:
+ Console.WriteLine("良好");
+ break;
+ case <= 90:
+ Console.WriteLine("优秀");
+ break;
+ case <= 100:
+ Console.WriteLine("满分");
+ break;
+ default:
+ Console.WriteLine("成绩超过100分,请重新输入。");
+ break;
+ }
+ }catch (FormatException)
+ {
+ Console.WriteLine("输入格式错误,请输入数字。");
+ return;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("发生异常:{0}", ex.Message);
+ return;
+ }
+
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson18_循环语句while/Lesson18_循环语句while.csproj b/C#入门/Lesson18_循环语句while/Lesson18_循环语句while.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson18_循环语句while/Lesson18_循环语句while.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson18_循环语句while/Program.cs b/C#入门/Lesson18_循环语句while/Program.cs
new file mode 100644
index 0000000..e495a43
--- /dev/null
+++ b/C#入门/Lesson18_循环语句while/Program.cs
@@ -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
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson19_循环语句dowhile/Lesson19_循环语句dowhile.csproj b/C#入门/Lesson19_循环语句dowhile/Lesson19_循环语句dowhile.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson19_循环语句dowhile/Lesson19_循环语句dowhile.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson19_循环语句dowhile/Program.cs b/C#入门/Lesson19_循环语句dowhile/Program.cs
new file mode 100644
index 0000000..9818afb
--- /dev/null
+++ b/C#入门/Lesson19_循环语句dowhile/Program.cs
@@ -0,0 +1,41 @@
+using System;
+namespace Lesson19_循环语句dowhile
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点一 基本语法
+ //和while循环类似,do while循环也是一种循环语句。
+ //区别在于do while循环会先执行一次循环体,然后再判断条件是否满足。
+ //do while循环的语法如下:
+ //do
+ //{
+ // // 循环体
+ //} while (条件);
+ //do while循环会先执行一次循环体,然后再判断条件是否满足。
+ #endregion
+
+ #region 知识点二 使用示例
+ int a = 1;
+ do
+ {
+ Console.WriteLine("a的值是{0}",a);
+ a++;
+ break;//防止死循环
+ } while (a>=2);
+ #endregion
+
+ #region 知识点三 嵌套应用和流程语句
+ //if switch while dowhile都可以嵌套使用
+ do
+ {
+ Console.WriteLine("111");
+ continue;//这个循环只会打印一边111,continue是回到while判断的地方而不是回到do
+ Console.WriteLine("222");//这串代码永远不会被运行
+ } while (false);
+ #endregion
+
+ }
+ }
+}
diff --git a/C#入门/Lesson19_循环语句for/Lesson20_循环语句for.csproj b/C#入门/Lesson19_循环语句for/Lesson20_循环语句for.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson19_循环语句for/Lesson20_循环语句for.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson19_循环语句for/Program.cs b/C#入门/Lesson19_循环语句for/Program.cs
new file mode 100644
index 0000000..46bdb9f
--- /dev/null
+++ b/C#入门/Lesson19_循环语句for/Program.cs
@@ -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
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson2变量练习/Lesson2变量练习.csproj b/C#入门/Lesson2变量练习/Lesson2变量练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson2变量练习/Lesson2变量练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson2变量练习/Program.cs b/C#入门/Lesson2变量练习/Program.cs
new file mode 100644
index 0000000..31edcf1
--- /dev/null
+++ b/C#入门/Lesson2变量练习/Program.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace Lesson2变量
+{
+ class classwork
+ {
+ static void Main(string[] args)
+ {
+ double num = 36.6;
+ Console.WriteLine(num);
+ string name, sex, addr;
+ name = "zj";
+ sex = "male";
+ addr = "jssszsgyyq";
+ int age = 21;
+ float hight = 192f, weight = 79.5f;
+ Console.WriteLine("年龄:" + age);
+ Console.WriteLine($"姓名:{name}\n年龄:{age}\n身高:{hight}体重:{weight}家庭住址:{addr}");
+ }
+ }
+}
diff --git a/C#入门/Lesson4变量的命名规则/Lesson4变量的命名规则.csproj b/C#入门/Lesson4变量的命名规则/Lesson4变量的命名规则.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson4变量的命名规则/Lesson4变量的命名规则.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson4变量的命名规则/Program.cs b/C#入门/Lesson4变量的命名规则/Program.cs
new file mode 100644
index 0000000..4ea5297
--- /dev/null
+++ b/C#入门/Lesson4变量的命名规则/Program.cs
@@ -0,0 +1,51 @@
+using System;
+namespace Lesson4
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 命名细则
+ //变量命名细则
+ //1不能重名
+ //2不能以数字开头
+ //3不能使用程序关键字
+ //4不能有特殊符号(下划线除外)
+
+ //建议的命名规则:变量名用英文,并且有变量的含义
+ //不建议用汉字命名
+
+
+ //eg重复
+ int i = 1;
+ string i = "123";
+
+ //eg数字开头
+ int 1i = 1;
+
+ //eg使用程序关键字(蓝色的
+ int string = 1;
+ //函数名不是关键字
+ int Main = 1;
+
+ //特殊符号
+ int re@ = 1;
+
+ //建议规则变量名用英文,并且有变量的含义
+ string myName = "ZJ";
+ #endregion
+
+
+
+ #region 常用命名规则
+ //驼峰命名法,首字母小写,之后单词首字母大写
+ string myName = "ZXJ";
+ //帕斯卡命名法——所有单词首字母都大写
+ string MyNmae = "ZXJ";
+
+
+ //潜在知识点,C#对大小写敏感,myName和MyName是两个不同的变量
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson5常量/Lesson5常量.csproj b/C#入门/Lesson5常量/Lesson5常量.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson5常量/Lesson5常量.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson5常量/Program.cs b/C#入门/Lesson5常量/Program.cs
new file mode 100644
index 0000000..e5fea19
--- /dev/null
+++ b/C#入门/Lesson5常量/Program.cs
@@ -0,0 +1,35 @@
+using System;
+namespace Lesson5
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 常量
+ //常量是指在程序运行过程中不会改变的值,必须初始化
+ //常量的定义:const 数据类型 常量名 = 值;
+ //常量名一般使用大写字母,多个单词之间用下划线分隔
+ const int MAX_VALUE = 100;
+ const string COMPANY_NAME = "ZJ Company";
+ Console.WriteLine($"最大值: {MAX_VALUE}, 公司名称: {COMPANY_NAME}");
+ #endregion
+ #region 只读变量
+ //只读变量在定义时可以赋值,也可以在构造函数中赋值,但不能在其他地方修改
+ class MyClass
+ {
+ public readonly int ReadOnlyValue;
+ public MyClass(int value)
+ {
+ ReadOnlyValue = value;
+ }
+ }
+ MyClass myObject = new MyClass(42);
+ Console.WriteLine($"只读变量值: {myObject.ReadOnlyValue}");
+ //关键词 const
+ //固定写法:
+ //const 变量类型 变量名 = 值;
+
+ #endregion
+ }
+}
+}
\ No newline at end of file
diff --git a/C#入门/Lesson6转义字符/Lesson6转义字符.csproj b/C#入门/Lesson6转义字符/Lesson6转义字符.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson6转义字符/Lesson6转义字符.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson6转义字符/Program.cs b/C#入门/Lesson6转义字符/Program.cs
new file mode 100644
index 0000000..c333296
--- /dev/null
+++ b/C#入门/Lesson6转义字符/Program.cs
@@ -0,0 +1,29 @@
+using System;
+namespace Lesson6
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ //什么是转义字符?
+ //转义字符是用来表示一些特殊字符的字符序列,通常以反斜杠(\)开头。
+ //例如,\n表示换行符,\t表示制表符,\"表示双引号,\\表示反斜杠本身。
+ //转义字符在字符串中用于表示那些不能直接输入的字符,或者需要特殊处理的字符。
+ //eg
+ Console.WriteLine("转义字符");
+ //固定写法 \字符
+ Console.WriteLine("Hello World!\n这是一个新行。");
+ Console.WriteLine("Hello World!\t这是一个制表符。");
+ Console.WriteLine("Hello World!\"这是一个双引号。\"");
+ Console.WriteLine("Hello World!\'这是一个单引号。\'");
+ Console.WriteLine("Hello World!\\这是一个反斜杠。");
+ Console.WriteLine("Hello World!\0这是一个空字符。");
+ Console.WriteLine("Hello World!\a这是一个响铃音字符。");
+
+ //知识点二
+ //取消转义字符
+ string str = @"Hello World!\n这是一个新行。";// /n不会被转义
+ Console.WriteLine(str);
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson7转义字符练习/Lesson7转义字符练习.csproj b/C#入门/Lesson7转义字符练习/Lesson7转义字符练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson7转义字符练习/Lesson7转义字符练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson7转义字符练习/Program.cs b/C#入门/Lesson7转义字符练习/Program.cs
new file mode 100644
index 0000000..6c58dd1
--- /dev/null
+++ b/C#入门/Lesson7转义字符练习/Program.cs
@@ -0,0 +1,13 @@
+using System;
+namespace Lesson7
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("我是小明\n今年18岁\n我的爱好是制作游戏\n我要好好学习,天天向上");
+ Console.WriteLine("我是小明\n今年18岁\n我的爱好是制作游戏\n我要好好学习,天天向上");
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson7隐式转换_类型转换/Lesson7隐式转换_类型转换.csproj b/C#入门/Lesson7隐式转换_类型转换/Lesson7隐式转换_类型转换.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson7隐式转换_类型转换/Lesson7隐式转换_类型转换.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson7隐式转换_类型转换/Program.cs b/C#入门/Lesson7隐式转换_类型转换/Program.cs
new file mode 100644
index 0000000..21812b9
--- /dev/null
+++ b/C#入门/Lesson7隐式转换_类型转换/Program.cs
@@ -0,0 +1,156 @@
+using System;
+namespace Lesson7
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("类型转换—隐式转换");
+ //什么是隐式转换?
+ //类型转换就是不同变量类型之间的转换
+ //隐式转换是指在不需要额外操作的情况下,编译器自动完成的转换。
+ //隐式转换规则:大范围装小范围
+
+ #region 知识点一 相同大类型之间的转换
+ //有符号 long->int->short->byte
+ long l = 1;
+ int i = 1;
+ short s = 1;
+ sbyte sb = 1;
+
+ l = i; //int 转 long
+
+ //i = l; long 转 int
+ //小的类型不能装大的 需要强制转换,不能隐式转换
+
+ //可以的转换:
+ l = i;
+ l = s;
+ l = sb;
+ i = s;
+ s = sb;
+
+
+
+ //无符号 ulong->uint->ushort->byte
+ ulong ul = 1;
+ uint ui = 1;
+ ushort us = 1;
+ byte b = 1;
+
+
+ //浮点数 double float decimal
+ decimal de = 1.1m;
+ double d = 1.1;
+ float f = 1.1f;
+ //decimal没有办法用隐式转换的形式去存储double和float
+ //de = d;
+ //de = f;
+ d = f;//float 是可以转 double 的
+
+
+ //特殊类型 bool char string
+ //他们之间不存在隐式转换
+ bool b1 = true;
+ char c = 'a';
+ string str = "Hello World";
+
+ #endregion
+
+
+ #region 知识点二 不同大类型之间的转换
+
+ #region 无符号装有符号
+ // 无符号
+ byte b2 = 1;
+ ushort us2 = 1;
+ uint ui2 = 1;
+ ulong ul2 = 1;
+ // 有符号
+ sbyte sb2 = 1;
+ short s2 = 1;
+ int i2 = 1;
+ long l2 = 1;
+
+ // 无符号装有符号
+ // 有符号的变量无法隐式转换为无符号的变量 eg:负数情况
+ //b2 = sb2;
+ //us2 = sb2;
+
+ // 有符号装无符号
+ // 无符号的变量可以隐式转换为有符号的变量
+ // 但需要注意的是,如果无符号变量的值大于有符号变量的最大值,则会发生溢出
+ //i2 = ui2;
+ i2 = b2;
+
+ #endregion
+
+ #region 浮点数和整数之间(有符号、无符号)的转换
+ // 浮点数装整数
+ float f2 = 1.1f;
+ double d2 = 1.1;
+ decimal de2 = 1.1m;
+ //浮点数可以装载任何类型的整数(有符号、无符号)
+ f2 = l2;
+ f2 = ul2;
+ f2 = 1000000000000000000; // 1.0E+20
+ Console.WriteLine(f2); // 输出 1.0E+20
+
+ //decimal不能隐式存储浮点数
+ //但是可以隐式存储整数
+ de = l2;
+ de = ul2;
+
+ //double->float->所有整形
+ //decimal->所有整形
+
+ //整数是不能隐式存储浮点数的,因为浮点数有小数部分
+ //i2 = f2; // 错误,不能隐式转换
+
+ #endregion
+
+ #region 特殊类型和其他类型之间的转换
+ // bool
+
+ //bool bo2 = true;
+ //bo2 = i2;
+ //bo2 = ui2;
+ //bo2 = f2;
+ //i2 = bo2;
+ //ui2 = bo2;
+ //bool无法与其他类型隐式转换
+
+
+ // char
+ char c2 = 'a';
+ //c2 = i2;
+ //c2 = ui2;
+ //c2 = f2;
+ //c2 = str;
+ //char 可以隐式转换为 整数类型 和 浮点型
+ //char转换后的值是其对应的ASCII编码值
+ i2 = c2;
+ Console.WriteLine(i2);
+ f2 = c2;
+ Console.WriteLine(f2);
+ ui2 = c2;
+ Console.WriteLine(ui2);
+ //str = c2;
+
+
+ // string
+ #endregion
+
+ #endregion
+
+
+ //总结:
+ //隐式转换是编译器自动完成的转换,不需要额外操作。
+ //隐式转换规则:大范围装小范围,高精度装低精度
+ //double->float->所有整形->char
+ //decimal不能隐式转换为浮点数,但可以隐式转换为整数。
+ //decimal->所有整形->char
+ //bool、string不参与隐式转换。
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson8_显式转换联系/Lesson8_显式转换练习.csproj b/C#入门/Lesson8_显式转换联系/Lesson8_显式转换练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson8_显式转换联系/Lesson8_显式转换练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson8_显式转换联系/Program.cs b/C#入门/Lesson8_显式转换联系/Program.cs
new file mode 100644
index 0000000..a05e012
--- /dev/null
+++ b/C#入门/Lesson8_显式转换联系/Program.cs
@@ -0,0 +1,28 @@
+using System;
+namespace Lesson8
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ int num1 = 24069;
+ Console.WriteLine(Convert.ToChar(num1));
+
+ Console.WriteLine();
+
+ int shuXue, yuWen, yingYu;
+ string name;
+ Console.Write("请输入姓名:");
+ name = Console.ReadLine();
+ Console.Write("请输入数学成绩:");
+ shuXue = Convert.ToInt32(Console.ReadLine());
+ Console.Write("请输入语文成绩:");
+ yuWen = Convert.ToInt32(Console.ReadLine());
+ Console.Write("请输入英语成绩:");
+ yingYu = Convert.ToInt32(Console.ReadLine());
+
+ Console.WriteLine($"你的成绩如下:\n语文:{yuWen}\n数学:{shuXue}\n英语:{yingYu}");
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson8_显示转换/Lesson8_显式转换.csproj b/C#入门/Lesson8_显示转换/Lesson8_显式转换.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson8_显示转换/Lesson8_显式转换.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson8_显示转换/Program.cs b/C#入门/Lesson8_显示转换/Program.cs
new file mode 100644
index 0000000..3ef0989
--- /dev/null
+++ b/C#入门/Lesson8_显示转换/Program.cs
@@ -0,0 +1,177 @@
+using System;
+namespace Lesson8
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("显式转换");
+ // 显式转换=手动处理 强制转换
+ #region 知识点一 括号强转
+ //作用:一般情况下,将高精度类型转换为低精度类型
+ //语法:变量类型 变量名 = (目标类型)变量名;
+ //注意:类型不兼容 精度问题 范围问题
+
+
+ //相同大类的整形
+ //有符号整形
+ sbyte sb = 1;
+ short s = 1;
+ int i = 40000;
+ long l = 1;
+ //s = i; //错误:类型不兼容
+ i = (int)l; //正确:手动转换
+ Console.WriteLine(i);
+ s = (short)i;//正确但注意:超过了short的范围
+ Console.WriteLine(s);
+
+ //无符号整形
+ byte b = 1;
+ ushort us = 1;
+ uint ui = 1;
+ ulong ul = 1;
+ ui = (uint)ul; //正确:手动转换
+ Console.WriteLine(ui);
+
+ //浮点数
+ float f = 1.0f;
+ double d = 1.123456789012345;
+
+ f = (float)d; //正确:手动转换
+ Console.WriteLine(f);//注意:精度损失
+
+
+
+ //无符号和有符号之间的转换
+ uint ui2 = 1;
+ int i2 = 1;
+ //ui2 = i2; //错误:类型不兼容
+ ui2 = (uint)i2; //正确:手动转换
+ Console.WriteLine(ui2);
+
+ i2 = -1; //负数
+ ui2 = (uint)i2;
+ Console.WriteLine(ui2); //注意:负数转换为无符号整形时,结果是一个很大的数
+
+
+ //浮点数和整形之间的转换,会直接截断小数部分
+ i2 = (int)1.2f;
+ Console.WriteLine(i2); //注意:小数部分被截断
+
+ //char和数值类型
+
+ char c = 'A'; //字符'A'的ASCII码是65
+ Console.WriteLine(c);
+ int asciiValue = (int)c; //将字符转换为ASCII码
+ Console.WriteLine(asciiValue);
+
+
+ //bool和string之间的转换,不能通过括号强转
+ bool bo = true;
+ //int i3 = (bool)bo; 错误:bool不能直接转换为int
+
+ string str = "123";
+ //i3 = int(str); 错误:string不能直接转换为int
+
+ #endregion
+
+ #region 知识点二 Parse方法
+ //作用:将字符串转换为其他类型
+ //语法:目标类型. Parse(字符串变量名);
+ //注意:如果字符串格式不正确,会抛出异常,必须是能够转换的类型
+
+
+ //有符号
+ string str2 = "123";
+ int i3 = int.Parse(str2); //正确:字符串转换为整数
+ Console.WriteLine(i3);
+ //i3 = int.Parse("fds"); 错误:字符串格式不正确,不是能够转换的类型,会抛出异常
+ //Console.WriteLine(i3);
+
+ short s3 = short.Parse("4");//正确:字符串转换为短整数
+ Console.WriteLine(s3);
+
+ //s3 = short.Parse("40000"); 错误:字符串格式不正确,超出了short的范围,会抛出异常
+ //Console.WriteLine(s3);
+
+
+ //无符号
+ //规则相同
+ Console.WriteLine(byte.Parse("1"));
+ Console.WriteLine(ushort.Parse("2"));
+ Console.WriteLine(uint.Parse("3"));
+ Console.WriteLine(ulong.Parse("4"));
+
+ //浮点数
+ double f3 = double.Parse("1.23456789"); //正确:字符串转换为双精度浮点数
+ Console.WriteLine(f3);
+ float f4 = float.Parse("1.23456789"); //正确:字符串转换为单精度浮点数
+ Console.WriteLine(f4);
+
+ //特殊类型
+ bool bo2 = bool.Parse("true"); //正确:字符串转换为布尔值
+ Console.WriteLine(bo2);
+ //char c3 = char.Parse(bo2); 错误:bool不能直接转换为char
+ //string str3 = string.Parse(bo2); 错误:bool不能直接转换为string
+ char c2 = char.Parse("A"); //正确:字符串转换为字符
+ Console.WriteLine(c2);
+
+ #endregion
+
+ #region 知识点三 Convert方法
+ //作用:更准确的将不同类型之间进行转换,支持更多类型的转换
+ //语法:Convert.To目标类型(变量名);
+ //注意:如果转换失败,会返回默认值,不会抛出异常
+
+ //转换字符串
+ int a = Convert.ToInt32("123"); //正确:字符串转换为整数
+ Console.WriteLine(a);
+
+ //a = Convert.ToInt32("fds"); 错误:字符串格式不正确,不是能够转换的类型,会抛出异常
+
+ a = Convert.ToInt32('A'); //正确:字符'A'的ASCII码是65
+ Console.WriteLine(a);
+
+ //精度更准确
+ a = Convert.ToInt32(1.5f); //正确:数字转换为int,会四舍五入
+ Console.WriteLine(a);
+
+ //特殊类型转换
+ a = Convert.ToInt32(true); //正确:bool转换为int,true为1,false为0
+ Console.WriteLine(a);
+
+ //每一个类型都有对应的Convert方法
+ short s4 = Convert.ToInt16("123"); //正确:字符串转换为短整数
+ uint ui3 = Convert.ToUInt32("123"); //正确:字符串转换为无符号整数
+ long s5 = Convert.ToInt64("123456789"); //正确:字符串转换为长整数
+
+ sbyte sb5 = Convert.ToSByte("123"); //正确:字符串转换为有符号字节
+ float f5 = Convert.ToSingle("1.23456789"); //正确:字符串转换为单精度浮点数
+ double d5 = Convert.ToDouble("1.23456789"); //正确:字符串转换为双精度浮点数
+ decimal dec = Convert.ToDecimal("1.23456789"); //正确:字符串转换为十进制数
+ bool bo3 = Convert.ToBoolean("true"); //正确:字符串转换为布尔值
+
+ #endregion
+
+ #region 知识点四 其他类型转string
+ //作用:将其他类型转换为字符串,拼接打印
+ //语法:变量名.ToString();
+
+ string str6 = 1.ToString();
+ Console.WriteLine(str6);
+ str6 = true.ToString();
+ Console.WriteLine(str6);
+ str6 = 1.23456789f.ToString();
+ Console.WriteLine(str6);
+ str6 = 'A'.ToString();
+ Console.WriteLine(str6);
+
+ //拼接
+ Console.WriteLine("拼接后的字符串"+1+true);//1和true会被转换为字符串,结果是"1True"
+ //eg:
+ str6 = "123" + 1 + true + 1.254;//默认调用了ToString()方法
+ Console.WriteLine(str6);
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson9_异常捕获/Lesson9_异常捕获.csproj b/C#入门/Lesson9_异常捕获/Lesson9_异常捕获.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson9_异常捕获/Lesson9_异常捕获.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson9_异常捕获/Program.cs b/C#入门/Lesson9_异常捕获/Program.cs
new file mode 100644
index 0000000..66bc02c
--- /dev/null
+++ b/C#入门/Lesson9_异常捕获/Program.cs
@@ -0,0 +1,52 @@
+using System;
+namespace Lesson8
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("异常捕获");
+ //作用:解决程序运行时的异常问题,避免卡死或崩溃
+
+ #region 语法
+ //基本语法:try{}catch{}尝试执行代码块中的代码,如果没有异常则继续执行
+ try
+ {
+ //可能会发生异常的代码块
+ }
+ catch(Exception e)//(Exception e)是可选项,e是异常对象,可以获取异常信息
+ {
+ //捕获异常的代码块
+ }
+ //可选部分:finally{}在try或catch执行完后执行的代码块,无论是否有异常都会执行
+ finally
+ {
+ //清理资源或执行收尾工作
+ }
+ //注意:异常捕获代码基本结构中,不需要加; 只有里面的代码需要加;
+ #endregion
+
+
+
+ #region 示例/实践
+ //示例:除数不能为0的异常捕获
+ try
+ {
+ Console.WriteLine("请输入一个整数:");
+ string str = Console.ReadLine();
+ int i = int.Parse(str);
+ Console.WriteLine("你输入了:" + i);
+ }
+ catch
+ {
+ Console.WriteLine("只能输入整数,请重新输入!");
+ }
+ finally
+ {
+ Console.WriteLine("程序执行完毕。");
+ }
+
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门/Lesson9_捕获异常联系/Lesson9_捕获异常练习.csproj b/C#入门/Lesson9_捕获异常联系/Lesson9_捕获异常练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门/Lesson9_捕获异常联系/Lesson9_捕获异常练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门/Lesson9_捕获异常联系/Program.cs b/C#入门/Lesson9_捕获异常联系/Program.cs
new file mode 100644
index 0000000..4067bf2
--- /dev/null
+++ b/C#入门/Lesson9_捕获异常联系/Program.cs
@@ -0,0 +1,50 @@
+using System;
+namespace Lesson8
+{
+ class program
+ {
+ static void Main(string[] args)
+ {
+ #region 输入数字练习
+ try
+ {
+ Console.Write("请输入一个数字:");
+ int num = int.Parse(Console.ReadLine());
+ Console.WriteLine($"你输入的数字是: {num}");
+ }
+ catch
+ {
+ Console.WriteLine("请你输入一个数字");
+ }
+ finally
+ {
+ Console.WriteLine("程序执行完毕!");
+ }
+ #endregion
+
+ #region 录入成绩练习
+ try
+ {
+ int yuWen, shuXue, yingYu;
+ Console.Write("请你输入你的名字:");
+ string name = Console.ReadLine();
+ Console.Write("请你输入你的语文成绩:");
+ yuWen = int.Parse(Console.ReadLine());
+ Console.Write("请你输入你的数学成绩:");
+ shuXue = int.Parse(Console.ReadLine());
+ Console.Write("请你输入你的英语成绩:");
+ yingYu = int.Parse(Console.ReadLine());
+ Console.WriteLine($"你的语文成绩是:{yuWen},你的数学成绩是{shuXue},你的英语成绩是:{yingYu}.");
+ }
+ catch
+ {
+ Console.WriteLine("成绩录入时发生了错误");
+ }
+ finally
+ {
+ Console.WriteLine("成绩录入完毕!");
+ }
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门实践教程/C#入门实践教程.sln b/C#入门实践教程/C#入门实践教程.sln
new file mode 100644
index 0000000..3643c04
--- /dev/null
+++ b/C#入门实践教程/C#入门实践教程.sln
@@ -0,0 +1,49 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36408.4
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "必备知识点_控制台相关", "必备知识点_控制台相关\必备知识点_控制台相关.csproj", "{06573DDE-AC71-42D8-98CA-98DD42A3C236}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "控制台相关练习题", "练习题\控制台相关练习题.csproj", "{88D217C8-8B85-4719-98E2-3A8FAF8489A3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "随机数", "随机数\随机数.csproj", "{A2D7438B-0455-43FA-A8E0-ED830E1DD30B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "随机数相关练习题", "随机数相关练习题\随机数相关练习题.csproj", "{1D204805-9EFC-4157-AA4F-A16BBD9CD95A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "小游戏", "小游戏\小游戏.csproj", "{7DD928E2-3B86-4EDB-92BB-E53BF3D0D069}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {06573DDE-AC71-42D8-98CA-98DD42A3C236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {06573DDE-AC71-42D8-98CA-98DD42A3C236}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {06573DDE-AC71-42D8-98CA-98DD42A3C236}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {06573DDE-AC71-42D8-98CA-98DD42A3C236}.Release|Any CPU.Build.0 = Release|Any CPU
+ {88D217C8-8B85-4719-98E2-3A8FAF8489A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {88D217C8-8B85-4719-98E2-3A8FAF8489A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {88D217C8-8B85-4719-98E2-3A8FAF8489A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {88D217C8-8B85-4719-98E2-3A8FAF8489A3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A2D7438B-0455-43FA-A8E0-ED830E1DD30B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A2D7438B-0455-43FA-A8E0-ED830E1DD30B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A2D7438B-0455-43FA-A8E0-ED830E1DD30B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A2D7438B-0455-43FA-A8E0-ED830E1DD30B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1D204805-9EFC-4157-AA4F-A16BBD9CD95A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1D204805-9EFC-4157-AA4F-A16BBD9CD95A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1D204805-9EFC-4157-AA4F-A16BBD9CD95A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1D204805-9EFC-4157-AA4F-A16BBD9CD95A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7DD928E2-3B86-4EDB-92BB-E53BF3D0D069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7DD928E2-3B86-4EDB-92BB-E53BF3D0D069}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7DD928E2-3B86-4EDB-92BB-E53BF3D0D069}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7DD928E2-3B86-4EDB-92BB-E53BF3D0D069}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {93EA734C-376F-48C2-9A20-13FCCD3D81DB}
+ EndGlobalSection
+EndGlobal
diff --git a/C#入门实践教程/小游戏/Program.cs b/C#入门实践教程/小游戏/Program.cs
new file mode 100644
index 0000000..293b8ac
--- /dev/null
+++ b/C#入门实践教程/小游戏/Program.cs
@@ -0,0 +1,370 @@
+#region 控制台基础设施
+using System.ComponentModel.Design;
+
+Console.BackgroundColor = ConsoleColor.Black;
+Console.Clear();
+int w = 50;
+int h = 30;
+Console.SetWindowSize(w, h);
+Console.SetBufferSize(w, h);
+Console.CursorVisible = false;
+#endregion
+
+#region 多个场景
+int nowScene = 1;
+try
+{
+ while (true)
+ {
+ switch (nowScene)
+ {
+ //主界面
+ case 1:
+ Console.Clear();
+ Console.WriteLine("开始场景");
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.SetCursorPosition(w / 2 - 3, h / 4);
+ Console.Write("寄掰游戏");
+ bool notExit = true;
+ int nowSceneIndex = 1;
+ char choice = 'w';
+ nowScene = 2;
+ while (notExit)
+ {
+ Console.SetCursorPosition(w / 2 - 3, h / 3 + 1);
+ Console.ForegroundColor = nowSceneIndex == 1 ? ConsoleColor.Red : ConsoleColor.White;
+ Console.Write("开始游戏");
+ Console.ForegroundColor = nowSceneIndex == 0 ? ConsoleColor.Red : ConsoleColor.White;
+ Console.SetCursorPosition(w / 2 - 3, h / 3 + 3);
+ Console.Write("退出游戏");
+
+ choice = Console.ReadKey(true).KeyChar;
+ switch (choice)
+ {
+ case '↑':
+ case 'w':
+ case 'W':
+ nowScene = 2;
+ nowSceneIndex = 1;
+ break;
+ case '↓':
+ case 's':
+ case 'S':
+ nowSceneIndex = 0;
+ nowScene = 3;
+ break;
+ case '\r':
+ notExit = false;
+ break;
+ }
+
+ }
+
+ break;
+
+ //游戏场景
+ case 2:
+ #region 游戏场景初始化
+ Console.Clear();
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.WriteLine("游戏场景");
+ Console.SetCursorPosition(2, h - 5);
+ Console.Write("1.WASD移动 2.靠近BOSS按J攻击");
+ #region 画框
+
+ Console.ForegroundColor = ConsoleColor.Red;
+ for (int i = 0; i < w; i += 2)
+ {
+ for (int j = 0; j < h; j++)
+ {
+ //Console.SetCursorPosition(25, 12);
+ //Console.WriteLine("当前i{0},j{1}", i, j);//测试用
+ if (i == 0 || j == 0)
+ {
+ Console.SetCursorPosition(i, j);
+ Console.Write("■");
+ }
+ else if (j == Console.BufferHeight - 6)
+ {
+ Console.SetCursorPosition(i, j);
+ Console.Write("■");
+ }
+ else if (i == Console.BufferWidth - 2 || j == Console.BufferHeight - 1)
+ {
+ Console.SetCursorPosition(i, j);
+ Console.Write("■");
+ }
+ }
+ }
+ #endregion
+ #endregion
+
+ #region 参数初始化
+ Random r = new Random();
+ notExit = true;
+ bool isBossDefeated = false;
+ bool isPlayerAlive = true;
+ bool isPlayerApproaching = false;
+ char movement;
+
+
+ //BOSS参数
+ string bossIcon = "■";
+ int bossHP = 100;
+ int bossAttackMax = 120;
+ int bossAttackMin = 100;
+ int bossDefense = 5;
+ int bossLocationX = r.Next(2, w - 2);
+ int bossLocationY = r.Next(1, h - 7);
+ while (bossLocationX < 2 || bossLocationY < 2 || bossLocationX > w - 4 || bossLocationY > h - 8)
+ {
+ bossLocationX = r.Next(2, w - 2);
+ bossLocationY = r.Next(1, h - 7);
+ }
+
+ //玩家参数
+ string playerIcon = "●";
+ int playerHP = 100;
+ int playerAttackMax = 12;
+ int playerAttackMin = 7;
+ int playerLocationX = r.Next(2, w - 2);
+ int playerLocationY = r.Next(1, h - 7);
+ while (playerLocationX == bossLocationX && playerLocationY == bossLocationY)
+ {
+ playerLocationX = r.Next(2, w - 2);
+ playerLocationY = r.Next(1, h - 7);
+ }
+ #endregion
+
+
+
+
+ while (notExit)
+ {
+ #region 画玩家
+ if (playerHP > 0)
+ {
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.SetCursorPosition(playerLocationX, playerLocationY);
+ Console.WriteLine(playerIcon);
+ }
+ #endregion
+
+ #region 画BOSS
+ if (bossHP > 0)
+ {
+ Console.SetCursorPosition(bossLocationX, bossLocationY);
+ Console.ForegroundColor = ConsoleColor.Yellow;
+ Console.Write(bossIcon);
+ }
+ #endregion
+
+ #region 判断玩家是否到达BOSS位置
+ if (playerLocationY == bossLocationY && playerLocationX == bossLocationX ||
+ playerLocationY == bossLocationY && playerLocationX == bossLocationX - 1 ||
+ playerLocationY == bossLocationY && playerLocationX == bossLocationX + 1)
+ {
+ isPlayerApproaching = true;
+ while (isPlayerAlive)
+ {
+ Console.SetCursorPosition(2, h - 4);
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine("Press J to join fight!");
+ movement = Console.ReadKey(true).KeyChar;
+ if (movement == 'J' || movement == 'j')
+ {
+ int round = 1;
+ bool isDefend = false;
+ int damage;
+ #region 初始化辅助界面
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine(" ");
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine("Combat start!");
+ Thread.Sleep(2000);
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine(" ");
+ #endregion
+ while (isPlayerAlive)
+ {
+ damage = 0;
+ Console.SetCursorPosition(2, h - 5);
+ Console.WriteLine(" ");
+ if (bossHP <= 0)
+ {
+ isBossDefeated = true;
+ Console.SetCursorPosition(2, h - 5);
+ Console.WriteLine("你击败了BOSS,按下任何按键继续");
+ Thread.Sleep(1000);
+ isBossDefeated = true;
+ notExit = true;
+ nowScene = 3;
+ break;
+ }
+ if (playerHP <= 0)
+ {
+ isPlayerAlive = false;
+ Console.SetCursorPosition(2, h - 5);
+ Console.WriteLine("你被BOSS打败了,按下任何按键继续");
+ Thread.Sleep(1000);
+ notExit = true;
+ nowScene = 3;
+ break;
+ }
+
+ if (round % 2 != 0)
+ {
+ Console.SetCursorPosition(2, h - 5);
+ Console.WriteLine("现在是你的回合,按下1防御,按下2攻击");
+ movement = Console.ReadKey(true).KeyChar;
+ if (movement == '1')
+ {
+ isDefend = true;
+ Console.SetCursorPosition(2, h - 5);
+ Console.WriteLine("你选择了防御");
+ Thread.Sleep(2000);
+ }
+ else if (movement == '2')
+ {
+ isDefend = false;
+ damage = r.Next(playerAttackMin, playerAttackMax);
+ bossHP -= damage;
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine("你攻击了BOSS,造成了{0}点伤害,BOSS剩余血量{1}", damage, bossHP);
+ Thread.Sleep(2000);
+ }
+ }
+ else
+ {
+ Console.SetCursorPosition(2, h - 5);
+ Console.WriteLine("现在是BOSS的回合");
+ Thread.Sleep(2000);
+ if (isDefend = false)
+ {
+ damage = r.Next(bossAttackMin, bossAttackMax);
+ playerHP -= damage;
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine("boss攻击了你{0}点血,剩余{1}点血",damage,playerHP);
+ Thread.Sleep(2400);
+ }
+ else
+ {
+ damage = r.Next(bossAttackMin, bossAttackMax) / 2; //防御时伤害减半
+ playerHP -= damage;
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine("boss攻击了你{0}点血,剩余{1}点血", damage, playerHP);
+ Thread.Sleep(2500);
+ }
+
+ }
+ round++;
+ }
+ if (isBossDefeated)
+ {
+ notExit = false; //退出游戏场景
+ nowScene = 3; //进入结算场景
+ break;
+ }
+ }
+ else
+ {
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine(" ");
+ break;
+ }
+ notExit = false; //退出游戏场景
+ nowScene = 3; //进入结算场景
+ break;
+ }
+ }
+ #endregion
+
+ #region 移动读取和处理
+ movement = Console.ReadKey(true).KeyChar;
+ //test
+ Console.SetCursorPosition(2, h - 2);
+ Console.WriteLine(movement);
+ #region 清除玩家当前位置
+ Console.SetCursorPosition(playerLocationX, playerLocationY);
+ Console.WriteLine(" ");
+ #endregion
+ switch (movement)
+ {
+ case 'w':
+ case 'W':
+ if (playerLocationY > 1)
+ {
+ playerLocationY--;
+ }
+ break;
+ case 's':
+ case 'S':
+ if (playerLocationY < h - 7)
+ {
+ playerLocationY++;
+ }
+ break;
+ case 'a':
+ case 'A':
+ if (playerLocationX > 2)
+ {
+ playerLocationX -= 1;
+ }
+ break;
+ case 'd':
+ case 'D':
+ if (playerLocationX < w - 4)
+ {
+ playerLocationX += 1;
+ }
+ break;
+ case 'j':
+ case 'J':
+ if (isPlayerApproaching == false)
+ {
+ Console.SetCursorPosition(2, h - 4);
+ Console.WriteLine("距离不足");
+ }
+ break;
+ case 'q':
+ case 'Q':
+ nowScene = 3; //退出游戏
+ break;
+ }
+ #endregion
+
+ #region 场景更新
+ if (nowScene == 3)
+ {
+ notExit = false;
+ break;
+ }
+ #endregion
+
+ }
+ break;
+
+ //结算场景
+ case 3:
+ Console.Clear();
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.WriteLine("结算场景");
+ //Console.WriteLine("恭喜你,成功营救公主!");
+ Console.WriteLine("Press any key to quit");
+ int block = Console.ReadKey(true).KeyChar;
+ Environment.Exit(0);
+ break;
+ }
+ }
+}
+catch (Exception e)
+{
+ Console.WriteLine("Error code:{0}",e);
+}
+finally
+{
+ Console.ResetColor(); //重置颜色为默认颜色
+ Console.Clear(); //清空控制台内容
+ Environment.Exit(0);
+}
+#endregion
\ No newline at end of file
diff --git a/C#入门实践教程/小游戏/小游戏.csproj b/C#入门实践教程/小游戏/小游戏.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门实践教程/小游戏/小游戏.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门实践教程/必备知识点_控制台相关/Program.cs b/C#入门实践教程/必备知识点_控制台相关/Program.cs
new file mode 100644
index 0000000..a20cc1f
--- /dev/null
+++ b/C#入门实践教程/必备知识点_控制台相关/Program.cs
@@ -0,0 +1,70 @@
+using System;
+namespace 必备知识点_控制台相关
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点一 输入输出
+ // 输出
+ Console.WriteLine("123");//输出后换行
+ Console.Write("456");//输出后不换行
+ // 输入
+ string str = Console.ReadLine(); //读取一行输入
+ char c = Console.ReadKey(/*这里加true不会将输入的内容显示在控制台上*/).KeyChar;//读取一个按键输入
+ #endregion
+
+ #region 知识点二 控制台其他方法
+ //1.清空
+ Console.Clear(); //清空控制台内容
+
+
+
+ //2.设置控制台大小
+ //2.1 设置控制台窗口大小
+ Console.SetWindowSize(1000, 500); //设置控制台窗口大小为100列,50行
+ //2.2 设置控制台缓冲区大小
+ Console.SetBufferSize(1000, 500); //设置控制台缓冲区大小为200列,100行
+ //注意:
+ //1.先设置窗口大小,再设置缓冲区大小,否则可能会报错。
+ //2.缓冲区大小必须大于等于窗口大小,否则会报错。
+ //3.窗口的大小不能超过屏幕的大小,否则会报错。
+
+
+
+ //3.设置光标位置
+ //控制台左上角为(0,0),右下角为(控制台宽度-1, 控制台高度-1)
+ Console.SetCursorPosition(10, 10); //设置光标位置为(10,10)
+ Console.WriteLine("123");
+ //注意:
+ //1.光标位置不能超过控制台的大小,否则会报错。
+ //2.横纵距离单位不同,视觉上大约1y=2x
+
+
+
+ //4.设置颜色
+ //4.1 设置文字颜色(前景色)
+ Console.ForegroundColor = ConsoleColor.Red; //设置文字颜色为红色
+ //4.2 设置背景颜色
+ Console.BackgroundColor = ConsoleColor.Blue; //设置背景颜色为蓝色
+ Console.WriteLine("现在是红色文字,蓝色背景");
+ //4.3 重置颜色
+ Console.ResetColor(); //重置颜色为默认颜色
+ Console.Clear(); //重置后要清空控制台内容,否则颜色不会改变
+ Console.WriteLine("现在是默认颜色文字,默认背景");
+
+
+
+ //5.光标显影
+ Console.CursorVisible = false; //设置光标不可见
+ //注意:设置光标不可见后,光标位置仍然可以通过SetCursorPosition方法设置,但不会显示出来。
+
+
+
+ //6.关闭控制台
+ Environment.Exit(0); //退出程序,参数为退出码,0表示正常退出,非0表示异常退出
+ //注意:在调试模式时,不会自动关闭,在exe中才能体现。
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门实践教程/必备知识点_控制台相关/必备知识点_控制台相关.csproj b/C#入门实践教程/必备知识点_控制台相关/必备知识点_控制台相关.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门实践教程/必备知识点_控制台相关/必备知识点_控制台相关.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门实践教程/练习题/Program.cs b/C#入门实践教程/练习题/Program.cs
new file mode 100644
index 0000000..7a57559
--- /dev/null
+++ b/C#入门实践教程/练习题/Program.cs
@@ -0,0 +1,68 @@
+Console.ForegroundColor = ConsoleColor.Yellow; //设置文字颜色为绿色
+Console.BackgroundColor = ConsoleColor.Red; //设置背景颜色为黑色
+Console.SetWindowSize(50, 25);
+Console.SetBufferSize(50, 25);
+Console.CursorVisible = false;
+try
+{
+ char dis;
+ int x=0, y=0;
+ while (true)
+ {
+ Console.Clear();
+ Console.SetCursorPosition(x, y);
+ Console.Write("■");
+ dis = Console.ReadKey(true).KeyChar;
+ switch (dis)
+ {
+ case 'w':
+ case 'W':
+ y--;
+ if (y < 0)
+ {
+ y = 0; //防止光标位置小于0
+ }
+ break;
+ case 'a':
+ case 'A':
+ x -= 2;
+ if (x < 0)
+ {
+ x = 0; //防止光标位置小于0
+ }
+ break;
+ case 's':
+ case 'S':
+ y++;
+ if (y > Console.BufferHeight - 1)
+ {
+ y = Console.BufferHeight - 1; //防止光标位置超过缓冲区高度
+ }
+ break;
+ case 'd':
+ case 'D':
+ x += 2;
+ if ( x > Console.BufferWidth - 2)
+ {
+ x = Console.BufferWidth - 2;
+
+ }
+ break;
+ }
+
+
+
+
+ }
+
+}catch (Exception ex)
+{
+ Console.WriteLine($"发生异常: {ex.Message}");
+}
+finally
+{
+ Console.ResetColor(); //重置颜色为默认颜色
+ Console.Clear(); //清空控制台内容
+ Console.WriteLine("程序结束");
+ Environment.Exit(0);
+}
diff --git a/C#入门实践教程/练习题/控制台相关练习题.csproj b/C#入门实践教程/练习题/控制台相关练习题.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门实践教程/练习题/控制台相关练习题.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门实践教程/随机数/Program.cs b/C#入门实践教程/随机数/Program.cs
new file mode 100644
index 0000000..4418248
--- /dev/null
+++ b/C#入门实践教程/随机数/Program.cs
@@ -0,0 +1,24 @@
+using System;
+namespace 随机数
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点一 生成随机数对象
+ //固定写法
+ // Random 关键字
+ Random r = new Random();
+ #endregion
+
+ #region 知识点二 生成随机数
+ int i = r.Next(); //生成一个非负随机整数
+ Console.WriteLine(i);
+ i = r.Next(100); //生成一个非负随机整数,范围为[0, 100)
+ Console.WriteLine(i);
+ i = r.Next(50, 100); //生成一个非负随机整数,范围为[50, 100)
+ Console.WriteLine(i);
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#入门实践教程/随机数/随机数.csproj b/C#入门实践教程/随机数/随机数.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门实践教程/随机数/随机数.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#入门实践教程/随机数相关练习题/Program.cs b/C#入门实践教程/随机数相关练习题/Program.cs
new file mode 100644
index 0000000..90cb25e
--- /dev/null
+++ b/C#入门实践教程/随机数相关练习题/Program.cs
@@ -0,0 +1,34 @@
+Random r = new Random();
+int bossHealth = 20;
+int bossDefense = 10;
+int round = 1;
+try
+{
+ Console.WriteLine("游戏开始");
+ while (true)
+ {
+ int attack = r.Next(8, 13);
+ Console.WriteLine("当前第{0}回合",round);
+ if (attack >= bossDefense)
+ {
+ bossHealth -= attack - bossDefense;
+ Console.WriteLine("你攻击了BOSS,造成了" + attack + "点伤害\n" + "BOSS剩余血量:" + bossHealth);
+ }else
+ {
+ Console.WriteLine("你的攻击被BOSS防御住了,造成了0点伤害");
+ }
+ round++;
+ if (bossHealth <= 0)
+ {
+ Console.WriteLine("你打赢了BOSS,共使用了{0}回合",round-1);
+ break;
+ }
+ }
+}catch (Exception ex)
+{
+ Console.WriteLine("错误代码: " + ex.Message);
+}
+finally
+{
+ Console.WriteLine("游戏结束");
+}
diff --git a/C#入门实践教程/随机数相关练习题/随机数相关练习题.csproj b/C#入门实践教程/随机数相关练习题/随机数相关练习题.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#入门实践教程/随机数相关练习题/随机数相关练习题.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/C#基础.sln b/C#基础/C#基础.sln
new file mode 100644
index 0000000..560119e
--- /dev/null
+++ b/C#基础/C#基础.sln
@@ -0,0 +1,175 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36408.4
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{27B93A9C-0FF2-4DCD-B0B3-D3C2ABE36381}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson1_枚举", "Lesson1_枚举\Lesson1_枚举.csproj", "{1131C91A-8FF6-48E1-B1BF-165650F15D05}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson1_ 枚举练习", "Lesson1_ 枚举练习\Lesson1_ 枚举练习.csproj", "{51244337-7936-4557-9192-773876FACD3D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson2_一维数组", "Lesson2_一维数组\Lesson2_一维数组.csproj", "{2C6D3608-AA58-46D1-BF36-C647495915A8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson2_一维数组练习", "Lesson2_数组练习\Lesson2_一维数组练习.csproj", "{BAA139CE-93A7-4E95-AF05-1BD376B19F2C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson3_二维数组", "Lesson3_二维数组\Lesson3_二维数组.csproj", "{C521F9D9-D58F-40F8-B5B7-67E7FC6B0433}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson3_二维数组练习题", "Lesson3_二维数组练习题\Lesson3_二维数组练习题.csproj", "{79F5FDB5-6653-446B-B56F-DF5812047233}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson4_交错数组", "Lesson4_交错数组\Lesson4_交错数组.csproj", "{46659CA6-5C9D-466C-9F85-BFECD7A5DA7D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson5_值类型和引用类型", "Lesson5_值类型和引用类型\Lesson5_值类型和引用类型.csproj", "{A2FB3021-8D7C-4422-B65E-C8295C9D46B3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson6_特殊的引用类型string", "Lesson6_特殊的引用类型string\Lesson6_特殊的引用类型string.csproj", "{34CEE0D5-059E-41F3-B315-80F74F671CB1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson7_函数", "Lesson7_函数\Lesson7_函数.csproj", "{9BA8FD2E-8265-4346-8AD3-4E3C1A0E539F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson7_函数练习", "Lesson7_函数练习\Lesson7_函数练习.csproj", "{107DF984-2089-4E81-91E1-C2D8D0BD75F6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson8_ref和out", "Lesson8_ref和out\Lesson8_ref和out.csproj", "{D626A1F8-B072-4DC2-B6BE-98A1B9BC9761}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson8_ref和out练习", "Lesson8_ref和out练习\Lesson8_ref和out练习.csproj", "{DB7E47D3-E121-4EC6-8B0E-9F436217D228}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson9_变长参数和参数默认值", "Lesson9_变长参数和参数默认值\Lesson9_变长参数和参数默认值.csproj", "{7FF87EE5-8F53-404C-BB4E-14151D411519}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson9_变长参数和参数默认值练习", "Lesson9_变长参数和参数默认值练习\Lesson9_变长参数和参数默认值练习.csproj", "{7957688A-3355-48DD-8C9F-7EEE91B66400}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson10_函数重载", "Lesson10_函数重载\Lesson10_函数重载.csproj", "{202E2B5E-DBC6-4100-9651-B6AC520A4CF5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson10_函数重载练习", "Lesson10_函数重载练习\Lesson10_函数重载练习.csproj", "{76A13792-153D-4D51-9ACA-B8B12000EFAF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson11_递归函数", "Lesson11_递归函数\Lesson11_递归函数.csproj", "{15F9E2CA-5E65-4147-BE9B-7563353B9676}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson11_递归函数练习", "Lesson11_递归函数练习\Lesson11_递归函数练习.csproj", "{F25A3D9E-3C4E-4984-9910-DBF14EEB4113}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson12_结构体", "Lesson12_结构体\Lesson12_结构体.csproj", "{49507514-25F2-453E-BBC3-57E1AA694B9B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson12_结构体练习", "Lesson12_结构体练习\Lesson12_结构体练习.csproj", "{C6E420B1-EE2F-4517-9952-FBEDC9C7BA43}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson13_冒泡排序", "Lesson13_冒泡排序\Lesson13_冒泡排序.csproj", "{68510D96-BECD-4B48-84B6-8D17975A74AE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson13_冒泡排序练习", "Lesson13_冒泡排序练习\Lesson13_冒泡排序练习.csproj", "{58DE0727-D9EB-4F96-95D8-54F275449649}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson14_选择排序", "Lesson14_选择排序\Lesson14_选择排序.csproj", "{A0279ACE-B0A8-43C9-86B8-D45B0A25BF24}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson14_选择排序练习", "Lesson14_选择排序练习\Lesson14_选择排序练习.csproj", "{D0B92715-B833-4513-AE97-C20101437297}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {27B93A9C-0FF2-4DCD-B0B3-D3C2ABE36381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {27B93A9C-0FF2-4DCD-B0B3-D3C2ABE36381}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {27B93A9C-0FF2-4DCD-B0B3-D3C2ABE36381}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {27B93A9C-0FF2-4DCD-B0B3-D3C2ABE36381}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1131C91A-8FF6-48E1-B1BF-165650F15D05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1131C91A-8FF6-48E1-B1BF-165650F15D05}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1131C91A-8FF6-48E1-B1BF-165650F15D05}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1131C91A-8FF6-48E1-B1BF-165650F15D05}.Release|Any CPU.Build.0 = Release|Any CPU
+ {51244337-7936-4557-9192-773876FACD3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {51244337-7936-4557-9192-773876FACD3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {51244337-7936-4557-9192-773876FACD3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {51244337-7936-4557-9192-773876FACD3D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2C6D3608-AA58-46D1-BF36-C647495915A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2C6D3608-AA58-46D1-BF36-C647495915A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2C6D3608-AA58-46D1-BF36-C647495915A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2C6D3608-AA58-46D1-BF36-C647495915A8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BAA139CE-93A7-4E95-AF05-1BD376B19F2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BAA139CE-93A7-4E95-AF05-1BD376B19F2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BAA139CE-93A7-4E95-AF05-1BD376B19F2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BAA139CE-93A7-4E95-AF05-1BD376B19F2C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C521F9D9-D58F-40F8-B5B7-67E7FC6B0433}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C521F9D9-D58F-40F8-B5B7-67E7FC6B0433}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C521F9D9-D58F-40F8-B5B7-67E7FC6B0433}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C521F9D9-D58F-40F8-B5B7-67E7FC6B0433}.Release|Any CPU.Build.0 = Release|Any CPU
+ {79F5FDB5-6653-446B-B56F-DF5812047233}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {79F5FDB5-6653-446B-B56F-DF5812047233}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {79F5FDB5-6653-446B-B56F-DF5812047233}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {79F5FDB5-6653-446B-B56F-DF5812047233}.Release|Any CPU.Build.0 = Release|Any CPU
+ {46659CA6-5C9D-466C-9F85-BFECD7A5DA7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {46659CA6-5C9D-466C-9F85-BFECD7A5DA7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {46659CA6-5C9D-466C-9F85-BFECD7A5DA7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {46659CA6-5C9D-466C-9F85-BFECD7A5DA7D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A2FB3021-8D7C-4422-B65E-C8295C9D46B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A2FB3021-8D7C-4422-B65E-C8295C9D46B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A2FB3021-8D7C-4422-B65E-C8295C9D46B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A2FB3021-8D7C-4422-B65E-C8295C9D46B3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {34CEE0D5-059E-41F3-B315-80F74F671CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {34CEE0D5-059E-41F3-B315-80F74F671CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {34CEE0D5-059E-41F3-B315-80F74F671CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {34CEE0D5-059E-41F3-B315-80F74F671CB1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9BA8FD2E-8265-4346-8AD3-4E3C1A0E539F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9BA8FD2E-8265-4346-8AD3-4E3C1A0E539F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9BA8FD2E-8265-4346-8AD3-4E3C1A0E539F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9BA8FD2E-8265-4346-8AD3-4E3C1A0E539F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {107DF984-2089-4E81-91E1-C2D8D0BD75F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {107DF984-2089-4E81-91E1-C2D8D0BD75F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {107DF984-2089-4E81-91E1-C2D8D0BD75F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {107DF984-2089-4E81-91E1-C2D8D0BD75F6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D626A1F8-B072-4DC2-B6BE-98A1B9BC9761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D626A1F8-B072-4DC2-B6BE-98A1B9BC9761}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D626A1F8-B072-4DC2-B6BE-98A1B9BC9761}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D626A1F8-B072-4DC2-B6BE-98A1B9BC9761}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DB7E47D3-E121-4EC6-8B0E-9F436217D228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DB7E47D3-E121-4EC6-8B0E-9F436217D228}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DB7E47D3-E121-4EC6-8B0E-9F436217D228}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DB7E47D3-E121-4EC6-8B0E-9F436217D228}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7FF87EE5-8F53-404C-BB4E-14151D411519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7FF87EE5-8F53-404C-BB4E-14151D411519}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7FF87EE5-8F53-404C-BB4E-14151D411519}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7FF87EE5-8F53-404C-BB4E-14151D411519}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7957688A-3355-48DD-8C9F-7EEE91B66400}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7957688A-3355-48DD-8C9F-7EEE91B66400}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7957688A-3355-48DD-8C9F-7EEE91B66400}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7957688A-3355-48DD-8C9F-7EEE91B66400}.Release|Any CPU.Build.0 = Release|Any CPU
+ {202E2B5E-DBC6-4100-9651-B6AC520A4CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {202E2B5E-DBC6-4100-9651-B6AC520A4CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {202E2B5E-DBC6-4100-9651-B6AC520A4CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {202E2B5E-DBC6-4100-9651-B6AC520A4CF5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {76A13792-153D-4D51-9ACA-B8B12000EFAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {76A13792-153D-4D51-9ACA-B8B12000EFAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {76A13792-153D-4D51-9ACA-B8B12000EFAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {76A13792-153D-4D51-9ACA-B8B12000EFAF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {15F9E2CA-5E65-4147-BE9B-7563353B9676}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {15F9E2CA-5E65-4147-BE9B-7563353B9676}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {15F9E2CA-5E65-4147-BE9B-7563353B9676}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {15F9E2CA-5E65-4147-BE9B-7563353B9676}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F25A3D9E-3C4E-4984-9910-DBF14EEB4113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F25A3D9E-3C4E-4984-9910-DBF14EEB4113}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F25A3D9E-3C4E-4984-9910-DBF14EEB4113}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F25A3D9E-3C4E-4984-9910-DBF14EEB4113}.Release|Any CPU.Build.0 = Release|Any CPU
+ {49507514-25F2-453E-BBC3-57E1AA694B9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {49507514-25F2-453E-BBC3-57E1AA694B9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {49507514-25F2-453E-BBC3-57E1AA694B9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {49507514-25F2-453E-BBC3-57E1AA694B9B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C6E420B1-EE2F-4517-9952-FBEDC9C7BA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C6E420B1-EE2F-4517-9952-FBEDC9C7BA43}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C6E420B1-EE2F-4517-9952-FBEDC9C7BA43}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C6E420B1-EE2F-4517-9952-FBEDC9C7BA43}.Release|Any CPU.Build.0 = Release|Any CPU
+ {68510D96-BECD-4B48-84B6-8D17975A74AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {68510D96-BECD-4B48-84B6-8D17975A74AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {68510D96-BECD-4B48-84B6-8D17975A74AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {68510D96-BECD-4B48-84B6-8D17975A74AE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {58DE0727-D9EB-4F96-95D8-54F275449649}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {58DE0727-D9EB-4F96-95D8-54F275449649}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {58DE0727-D9EB-4F96-95D8-54F275449649}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {58DE0727-D9EB-4F96-95D8-54F275449649}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A0279ACE-B0A8-43C9-86B8-D45B0A25BF24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A0279ACE-B0A8-43C9-86B8-D45B0A25BF24}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A0279ACE-B0A8-43C9-86B8-D45B0A25BF24}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A0279ACE-B0A8-43C9-86B8-D45B0A25BF24}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D0B92715-B833-4513-AE97-C20101437297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D0B92715-B833-4513-AE97-C20101437297}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D0B92715-B833-4513-AE97-C20101437297}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D0B92715-B833-4513-AE97-C20101437297}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {68808FF0-79EA-4FFD-9EA2-4A1EE2B2893B}
+ EndGlobalSection
+EndGlobal
diff --git a/C#基础/Lesson10_函数重载/Lesson10_函数重载.csproj b/C#基础/Lesson10_函数重载/Lesson10_函数重载.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson10_函数重载/Lesson10_函数重载.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson10_函数重载/Program.cs b/C#基础/Lesson10_函数重载/Program.cs
new file mode 100644
index 0000000..c1b4b18
--- /dev/null
+++ b/C#基础/Lesson10_函数重载/Program.cs
@@ -0,0 +1,90 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ #region 知识点一 基本概念
+ //重载概念
+ //在同意语句块class或struct中
+ //函数(方法)名相同
+ //参数的数量不同
+ //或者
+ //函数的数量相同,但参数的类型或顺序不同
+
+ //作用:
+ //1.命名一组功能相似的函数,减少函数名的数量,避免命名空间的污染
+ //2.提升程序可读性
+ #endregion
+
+
+
+ #region 知识点二 实例
+ //注意:
+ //1.重载和返回值类型没有关系,之和参数类型,个数,顺序有关
+ //2.调用时 程序会自己根据传入的参数类型判断使用哪一个重载
+
+
+ //基础函数
+ static int CalcSum(int a, int b)
+ {
+ return a + b;
+ }
+
+ //类型相同 数量不同
+ static int CalcSum(int a, int b, int c)
+ {
+ return a + b + c;
+ }
+
+ //类型不同 数量相同
+ static float CalcSum(float a, float b)
+ {
+ return a + b;
+ }
+
+
+ //类型不同 数量不同
+ static float CalcSum(float a, int b)
+ {
+ return a + b;
+ }
+
+
+ //数量相同 顺序不同
+ static float CalcSum(int a, float b)
+ {
+ return a + b;
+ }
+
+ //只要不是完全相同,都可以重载
+ //ref和out也可以视为一种改变
+ static float CalcSum(ref int a, float b)
+ {
+ return a + b;
+ }
+
+ //params可变参数也可以视为一种改变
+ static float CalcSum(ref int a, float b, params int[] arr)
+ {
+ return a + b;
+ }
+ #endregion
+
+
+
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine("基础函数:");
+ Console.WriteLine(CalcSum(1, 2));
+ Console.WriteLine("数量不同重载:");
+ Console.WriteLine(CalcSum(1, 2, 3));
+ Console.WriteLine("类型不同重载:");
+ Console.WriteLine(CalcSum(1.2f, 1.3f));
+ Console.WriteLine("类型数量都不同重载:");
+ Console.WriteLine(CalcSum(1.2f, 1));
+ Console.WriteLine("顺序不同重载:");
+ Console.WriteLine(CalcSum(1, 1.2f));
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson10_函数重载练习/Lesson10_函数重载练习.csproj b/C#基础/Lesson10_函数重载练习/Lesson10_函数重载练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson10_函数重载练习/Lesson10_函数重载练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson10_函数重载练习/Program.cs b/C#基础/Lesson10_函数重载练习/Program.cs
new file mode 100644
index 0000000..aeabfdf
--- /dev/null
+++ b/C#基础/Lesson10_函数重载练习/Program.cs
@@ -0,0 +1,91 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ static int Compare(int a, int b)
+ {
+ if (a > b)
+ {
+ return a;
+ }
+ else
+ {
+ return b;
+ }
+ }
+ static float Compare(float a, float b)
+ {
+ if (a > b)
+ {
+ return a;
+ }
+ else
+ {
+ return b;
+ }
+ }
+ static double Compare(double a, double b)
+ {
+ if (a > b)
+ {
+ return a;
+ }
+ else
+ {
+ return b;
+ }
+ }
+
+ static int CompareInf(params int[] a)
+ {
+ int max = 0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] > max)
+ {
+ max = a[i];
+ }
+ }
+ return max;
+ }
+ static float CompareInf(params float[] a)
+ {
+ float max = 0.0f;
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] > max)
+ {
+ max = a[i];
+ }
+ }
+ return max;
+ }
+ static double CompareInf(params double[] a)
+ {
+ double max = 0.0d;
+ for (int i = 0; i < a.Length; i++)
+ {
+ if (a[i] > max)
+ {
+ max = a[i];
+ }
+ }
+ return max;
+ }
+
+
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine(Compare(1, 2));
+ Console.WriteLine(Compare(2.1f, 3.2f));
+ Console.WriteLine(Compare(3.675475d, 4.6435432d));
+
+
+ Console.WriteLine(CompareInf(1,2,3,4,5,6,7));
+ Console.WriteLine(CompareInf(1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f));
+ Console.WriteLine(CompareInf(1.1d, 1.2d, 1.3d, 1.4d, 1.5d, 1.6d, 1.7d));
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson11_递归函数/Lesson11_递归函数.csproj b/C#基础/Lesson11_递归函数/Lesson11_递归函数.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson11_递归函数/Lesson11_递归函数.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson11_递归函数/Program.cs b/C#基础/Lesson11_递归函数/Program.cs
new file mode 100644
index 0000000..2f7067d
--- /dev/null
+++ b/C#基础/Lesson11_递归函数/Program.cs
@@ -0,0 +1,45 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ #region 知识点一 基本概念
+ //递归函数 就是 让函数自己调用自己
+ //static void Fun()
+ //{
+ // Fun();
+ //}
+ //注意:这样会爆内存
+ //所以 一个正确的递归函数必须要包括下面的特点
+ //1.必须有结束调用的条件
+ //2.用于条件判断的 这个条件 必须改变 能够达到停止的目的
+ #endregion
+
+
+
+
+ #region 知识点二 实例
+ //用递归函数打印出0到10
+ static void Print(int a = 0)
+ {
+ Console.WriteLine(a);
+ a++;
+ if (a <= 10)
+ {
+ Print(a);
+ }
+ else
+ {
+ return;
+ }
+ }
+ #endregion
+
+
+
+ static void Main(string[] args)
+ {
+ Print();
+ }
+ }
+}
diff --git a/C#基础/Lesson11_递归函数练习/Lesson11_递归函数练习.csproj b/C#基础/Lesson11_递归函数练习/Lesson11_递归函数练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson11_递归函数练习/Lesson11_递归函数练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson11_递归函数练习/Program.cs b/C#基础/Lesson11_递归函数练习/Program.cs
new file mode 100644
index 0000000..92c68ee
--- /dev/null
+++ b/C#基础/Lesson11_递归函数练习/Program.cs
@@ -0,0 +1,80 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ #region 练习题一 课上有不写了
+ #endregion
+
+
+
+ #region 练习题二
+ static int JieCheng(int max)
+ {
+ if (max == 0)
+ {
+ return 1;
+ }
+ else
+ {
+ return max * JieCheng(max - 1);
+ }
+
+ }
+
+ #endregion
+
+
+
+ #region 练习题三
+ static int JieChengHe(int num)
+ {
+ if (num == 1)
+ {
+ return JieCheng(1);
+ }
+ return JieCheng(num) + JieChengHe(num-1);
+ }
+ #endregion
+
+
+
+ #region 练习题四
+ static void Bamboo(float length, int day)
+ {
+ Console.WriteLine("长度为" + length);
+ length /= 2;
+ day--;
+ if (day < 0)
+ {
+ Console.WriteLine("长度为" + length);
+ return;
+ }
+ Bamboo(length, day);
+ }
+ #endregion
+
+
+ #region 练习题五
+ static bool Fun(int num)
+ {
+ Console.WriteLine(num);
+ return num == 200 || Fun(num + 1);
+ }
+ #endregion
+
+
+
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine(JieCheng(5));
+
+ Console.WriteLine(JieChengHe(10));
+
+ Bamboo(100,10);
+
+ Fun(0);
+ }
+ }
+}
diff --git a/C#基础/Lesson12_结构体/Lesson12_结构体.csproj b/C#基础/Lesson12_结构体/Lesson12_结构体.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson12_结构体/Lesson12_结构体.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson12_结构体/Program.cs b/C#基础/Lesson12_结构体/Program.cs
new file mode 100644
index 0000000..da71a5a
--- /dev/null
+++ b/C#基础/Lesson12_结构体/Program.cs
@@ -0,0 +1,115 @@
+using System;
+namespace Lesson
+{
+ #region 知识点一 基本概念
+ //结构体 是一种自定义变量类型 类似枚举需要自己定义
+ //他是数据和函数的集合
+ //在结构体中 可以声明各种变量和方法
+
+ //作用:用来表现存在关系的数据集合 比如用结构体变现学生 动物 人类等等
+ #endregion
+
+
+
+ #region 知识点二 基本语法
+ //1.结构体一般卸载 namespace语句块中
+ //2.结构体关键字 struct
+ //3.结构体中声明的变量不能直接初始化
+
+ struct StructName//可以是中文的
+ {
+ //第一部分
+ //变量(不能直接初始化
+
+ //第二部分
+ //构造函数(可选
+
+ //第三部分
+ //函数(一般情况下都有
+ }
+ //注意:结构体名字是帕斯卡命名法
+ #endregion
+
+
+
+ #region 知识点三 实例
+ struct Student
+ {
+ //变量
+ //年龄,性别,学号,姓名
+ #region 知识点五 访问修饰符
+ //修饰结构体中变量和方法 是否能够被外部使用
+ //public 公共的 可以被外部访问
+ //private 私有的 只能在内部使用
+ //默认不写 为private
+ #endregion
+ public int age;
+ public bool sex;
+ public int number;
+ public string name;
+
+
+ //结构体中可以包含其他结构体,但不能是本结构体
+ //构造函数
+ #region 知识点六 结构体的构造函数
+ //基本概念
+ //1.没有返回值
+ //2.函数名必须和结构体名相同
+ //3.必须有参数
+ //4.如果声明了构造函数 那么必须在其中队所有变量数据初始化
+ //5.结构体和构造函数可以重载,但是注意第4点
+
+ //构造函数一般用在外部,方便初始化使用的
+ public Student(int age, bool sex, int number, string name) //必须有参数
+ {
+ //新的关键字this,代表自己
+ this.age = age;//this.age是构造函数中写的age,而后面的age是结构体上面的声明的age
+ this.sex = sex;
+ this.number = number;
+ this.name = name;
+ }
+ #endregion
+
+
+
+ //函数
+ //表现这个数据结构的行为
+ //注意:在结构提中的方法,目前不需要加static关键字
+ public void Speak()
+ {
+ //在函数中可以直接使用结构体内部声明的变量
+ Console.WriteLine("我的名字是{0},今年{1}岁",name,age);
+ }
+ //函数可以根据需求写任意个
+ }
+
+ #endregion
+
+
+
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点四 结构体的使用
+ //变量的声明
+ //变量类型 变量名;
+ Student s1;
+ //如果没写后private打s1.是tab不补齐的
+ s1.age = 18;
+ s1.sex = false;
+ s1.number = 123;
+ s1.name = "HKK";
+ s1.Speak();
+
+ Student s2 = new Student(8,true,321,"KKH");
+ //上面的代码可以替代下面的代码
+ //s2.age = 8;
+ //s2.sex = true;
+ //s2.number = 321;
+ //s2.name = "KKH";
+ s2.Speak();
+ #endregion
+ }
+ }
+}
diff --git a/C#基础/Lesson12_结构体练习/Lesson12_结构体练习.csproj b/C#基础/Lesson12_结构体练习/Lesson12_结构体练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson12_结构体练习/Lesson12_结构体练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson12_结构体练习/Program.cs b/C#基础/Lesson12_结构体练习/Program.cs
new file mode 100644
index 0000000..a65b384
--- /dev/null
+++ b/C#基础/Lesson12_结构体练习/Program.cs
@@ -0,0 +1,179 @@
+using System;
+using System.Threading;
+namespace Lesson
+{
+ struct Member
+ {
+ public string name;
+ public bool sex;
+ public int age;
+ public string clas;
+ public string major;
+ public Member(string name, bool sex, int age, string clas, string major)
+ {
+ this.name = name;
+ this.sex = sex;
+ this.age = age;
+ this.clas = clas;
+ this.major = major;
+ }
+ public void PrintInfo()
+ {
+ Console.WriteLine("学员信息:");
+ Console.WriteLine($"姓名:{name}");
+ Console.WriteLine($"性别:{(sex ? "男" : "女")}"); // 将bool转换为中文
+ Console.WriteLine($"年龄:{age}");
+ Console.WriteLine($"班级:{clas}");
+ Console.WriteLine($"专业:{major}");
+ }
+ }
+ struct PlayerInfo
+ {
+ public string name;
+ public E_Occupation occupation;
+
+ public PlayerInfo(string name,E_Occupation occupation)
+ {
+ this.name = name;
+ this.occupation = occupation;
+ }
+
+ public void PrintInfo()
+ {
+ Console.WriteLine("玩家攻击信息");
+ switch (occupation)
+ {
+ case E_Occupation.Warrior:
+ Console.WriteLine($"{occupation}{name}释放了冲锋");
+ break;
+ case E_Occupation.Hunter:
+ Console.WriteLine($"{occupation}{name}释放了假死");
+ break;
+ case E_Occupation.Mage:
+ Console.WriteLine($"{occupation}{name}释放了奥数冲击");
+ break;
+ }
+ }
+ }
+ struct Monster
+ {
+ public string name;
+ public int atk;
+
+ public Monster(string name)
+ {
+ this.name = name;
+ Random r = new Random();
+ atk = r.Next(10,30);
+ }
+
+ public void Atk()
+ {
+ Console.WriteLine("{0}的攻击力为{1}",name,atk);
+ }
+ }
+
+ struct Atm
+ {
+ public string name;
+ public int atk;
+ public int def;
+ public int hp;
+
+ public Atm(string name,int atk,int def,int hp)
+ {
+ this.name = name;
+ this.atk = atk;
+ this.def = def;
+ this.hp = hp;
+ }
+
+ public void Atk(ref Boss monster)
+ {
+ monster.hp -= atk - monster.def;
+ Console.WriteLine("{0}攻击了{1}造成了{2}点伤害,{3}剩余{4}HP", name, monster.name, atk - monster.def,monster.name, monster.hp);
+ }
+ }
+
+
+ struct Boss
+ {
+ public string name;
+ public int atk;
+ public int def;
+ public int hp;
+ public Boss(string name, int atk, int def, int hp)
+ {
+ this.name = name;
+ this.atk = atk;
+ this.def = def;
+ this.hp = hp;
+ }
+
+ public void Atk(ref Atm atm)
+ {
+ atm.hp -= atk - atm.def;
+ Console.WriteLine("{0}攻击了{1}造成了{2}点伤害,{3}剩余{4}HP", name, atm.name, atk - atm.def,atm.name, atm.hp);
+ }
+ }
+
+
+
+ enum E_Occupation
+ {
+ ///
+ /// 战士
+ ///
+ Warrior,
+ ///
+ /// 猎人
+ ///
+ Hunter,
+ ///
+ /// 法师
+ ///
+ Mage
+ }
+ class Program
+ {
+
+ static void Main(string[] args)
+ {
+ Member m1 = new Member("123",true,18,"三年一班","计算机");
+ m1.PrintInfo();
+ Member m2 = new Member("321", false, 18, "一年三班", "算计机");
+ m2.PrintInfo();
+
+ PlayerInfo p1 = new PlayerInfo("HK", E_Occupation.Warrior);
+ p1.PrintInfo();
+
+
+ Monster[] monsters = new Monster[10];
+ for (int i = 0; i < monsters.Length; i++)
+ {
+ monsters[i] = new Monster("小怪兽"+i);
+ monsters[i].Atk();
+ }
+
+ Atm atm = new Atm("雷欧奥特曼",10,5,100);
+ Boss boss = new Boss("哥斯拉",8,4,100);
+ while (true)
+ {
+ atm.Atk(ref boss);
+ boss.Atk(ref atm);
+ if (boss.hp <= 0)
+ {
+ Console.WriteLine("你赢了");
+ break;
+ }
+ if (atm.hp <= 0)
+ {
+ Console.WriteLine("你输了");
+ break;
+ }
+ Console.WriteLine("按任意键继续");
+ Console.ReadKey(true);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson13_冒泡排序/Lesson13_冒泡排序.csproj b/C#基础/Lesson13_冒泡排序/Lesson13_冒泡排序.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson13_冒泡排序/Lesson13_冒泡排序.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson13_冒泡排序/Program.cs b/C#基础/Lesson13_冒泡排序/Program.cs
new file mode 100644
index 0000000..a1aac89
--- /dev/null
+++ b/C#基础/Lesson13_冒泡排序/Program.cs
@@ -0,0 +1,69 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ static void Print(int[] arr)
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ Console.Write(arr[i] + " ");
+ }
+ Console.WriteLine();
+ }
+ static void Main(string[] args)
+ {
+ #region 知识点一 排序的基本概念
+ //排序是计算机内经常进行的一种操作,其目的是将一组“无序”的记录调整为“有序的”
+ int[] arr = new int[] { 8, 7, 1, 5, 4, 2, 6, 3, 9};
+ #endregion
+ Print(arr);
+
+
+
+ #region 知识点二 基本原理
+ //两两相比
+ //不停比较
+ //不停交换
+ #endregion
+
+
+
+ bool isSort;//声明一个标识来保存是否进行交换的状态
+ #region 知识点三 代码实现
+ int temp;
+ for (int i = 0; i < arr.Length; i++)
+ {
+ isSort = false;
+ for (int j = 0; j < arr.Length - 1 - i; j++)//-i可以直接省去后面已经确定位置那一轮的比较
+ {
+ if (arr[j] > arr[j + 1])
+ {
+ isSort = true;//被交换了被表示true
+ temp = arr[j];
+ arr[j] = arr[j + 1];
+ arr[j + 1] = temp;
+ }
+ }
+ if (!isSort) { break; }//如果是true就继续交换,如果没有交换就false跳过这一轮
+ }
+ #endregion
+
+ Print(arr);
+ #region 知识点四 优化
+ //1.确定位置的数(极值)可以不用继续比了
+ //所以 没完成n轮 后面位置的数 就不用参与比较了
+
+ //2.特殊情况的优化
+ //比如在某一轮已经得到最终序列后,还会继续判断几轮,可以省去这几轮的时间
+ //
+ #endregion
+
+ #region 知识点五
+ #endregion
+
+ #region 知识点六
+ #endregion
+ }
+ }
+}
diff --git a/C#基础/Lesson13_冒泡排序练习/Lesson13_冒泡排序练习.csproj b/C#基础/Lesson13_冒泡排序练习/Lesson13_冒泡排序练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson13_冒泡排序练习/Lesson13_冒泡排序练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson13_冒泡排序练习/Program.cs b/C#基础/Lesson13_冒泡排序练习/Program.cs
new file mode 100644
index 0000000..36e89cd
--- /dev/null
+++ b/C#基础/Lesson13_冒泡排序练习/Program.cs
@@ -0,0 +1,59 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ static void Print(int[] arr)
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ Console.Write(arr[i] + " ");
+ }
+ Console.WriteLine();
+ }
+ static void Main(string[] args)
+ {
+ int[] arr = new int[20];
+ Random r = new Random();
+ for (int i = 0; i < arr.Length; i++)
+ {
+ arr[i] = r.Next(0,101);
+ }
+ Print(arr);
+ int temp;
+ bool isSort;
+ for (int i = 0; i < arr.Length; i++)
+ {
+ isSort = false;
+ for (int j = 0; j < arr.Length - 1 - i; j++)
+ {
+ if (arr[j] > arr[j + 1])
+ {
+ isSort = true;
+ temp = arr[j];
+ arr[j] = arr[j + 1];
+ arr[j + 1] = temp;
+ }
+ }
+ if (!isSort) { break; }
+ }
+ Print(arr);
+ for (int i = 0; i < arr.Length; i++)
+ {
+ isSort = false;
+ for (int j = 0; j < arr.Length - 1 - i; j++)
+ {
+ if (arr[j] < arr[j + 1])
+ {
+ isSort = true;
+ temp = arr[j];
+ arr[j] = arr[j + 1];
+ arr[j + 1] = temp;
+ }
+ }
+ if (!isSort) { break; }
+ }
+ Print(arr);
+ }
+ }
+}
diff --git a/C#基础/Lesson14_选择排序/Lesson14_选择排序.csproj b/C#基础/Lesson14_选择排序/Lesson14_选择排序.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson14_选择排序/Lesson14_选择排序.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson14_选择排序/Program.cs b/C#基础/Lesson14_选择排序/Program.cs
new file mode 100644
index 0000000..bd188bb
--- /dev/null
+++ b/C#基础/Lesson14_选择排序/Program.cs
@@ -0,0 +1,77 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ static void Print(int[] arr)
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ Console.Write(arr[i] + " ");
+ }
+ Console.WriteLine();
+ }
+
+ static void Main(string[] args)
+ {
+ #region 知识点一 基本原理
+ //新建中间商
+ //依次比较
+ //找出极值(最大或最小
+ //放入目标位置
+ //比较n轮
+ #endregion
+
+ #region 知识点二
+ //实现升序 把 大的 放在最后面
+ int[] arr = new int[] { 8, 7, 1, 5, 4, 2, 6, 3, 9 };
+ Print(arr);
+ ////第一步 声明一个中间商 来记录索引
+ ////每一轮开始 默认第一个都是极值
+ //int index = 0;
+ //第二步
+ //依次比较
+ //for (int n = 1; n < arr.Length; n++)
+ //{
+ // //第三步
+ // //找出极值(最大值)
+ // if (arr[index] < arr[n])
+ // {
+ // index = n;
+ // }
+ //}
+
+ ////第四步 放入目标位置
+ ////Length - 1 - 轮数
+ ////如果当前极值所在位置 就是目标位置 那就没必要交换了
+ //if (index < arr.Length - 1 - 轮数)
+ //{
+ // int temp = arr[index];
+ // arr[index] = arr[arr.Length - 1 -轮数];
+ // arr[arr.Length - 1 - 轮数] = temp;
+ //}
+
+ //第五步 比较m轮
+ for (int m = 0; m < arr.Length; m++)
+ {
+ int index = 0;
+ for (int n = 1; n < arr.Length - m; n++)
+ {
+ if (arr[index] < arr[n])
+ {
+ index = n;
+ }
+ }
+
+ if (index < arr.Length - 1 - m)
+ {
+ int temp = arr[index];
+ arr[index] = arr[arr.Length - 1 - m];
+ arr[arr.Length - 1 - m] = temp;
+ }
+ }
+ Print(arr);
+ #endregion
+ }
+ }
+}
diff --git a/C#基础/Lesson14_选择排序练习/Lesson14_选择排序练习.csproj b/C#基础/Lesson14_选择排序练习/Lesson14_选择排序练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson14_选择排序练习/Lesson14_选择排序练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson14_选择排序练习/Program.cs b/C#基础/Lesson14_选择排序练习/Program.cs
new file mode 100644
index 0000000..4e212f3
--- /dev/null
+++ b/C#基础/Lesson14_选择排序练习/Program.cs
@@ -0,0 +1,64 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ static void Print(int[] arr)
+ {
+ for (int i = 0; i < arr.Length; i++)
+ {
+ Console.Write(arr[i] + " ");
+ }
+ Console.WriteLine();
+ }
+ static void Main(string[] args)
+ {
+ int[] arr = new int[20];
+ Random r = new Random();
+ for (int i = 0;i < arr.Length; i++)
+ {
+ arr[i] = r.Next(1,101);
+ }
+ Print(arr);
+
+
+ for (int m = 0; m < arr.Length; m++)
+ {
+ int index = 0;
+ for (int n = 1; n < arr.Length - m; n++)
+ {
+ if (arr[index] < arr[n])
+ {
+ index = n;
+ }
+ }
+ if (index != arr.Length - 1 - m)
+ {
+ int temp = arr[index];
+ arr[index] = arr[arr.Length - 1 - m];
+ arr[arr.Length - 1 - m] = temp;
+ }
+ }
+ Print(arr);
+
+ for (int m = 0; m < arr.Length; m++)
+ {
+ int index = 0;
+ for (int n = 1; n < arr.Length - m; n++)
+ {
+ if (arr[index] > arr[n])
+ {
+ index = n;
+ }
+ }
+ if (index != arr.Length - 1 - m)
+ {
+ int temp = arr[index];
+ arr[index] = arr[arr.Length - 1 - m];
+ arr[arr.Length - 1 - m] = temp;
+ }
+ }
+ Print(arr);
+ }
+ }
+}
diff --git a/C#基础/Lesson1_ 枚举练习/Lesson1_ 枚举练习.csproj b/C#基础/Lesson1_ 枚举练习/Lesson1_ 枚举练习.csproj
new file mode 100644
index 0000000..30b1dd5
--- /dev/null
+++ b/C#基础/Lesson1_ 枚举练习/Lesson1_ 枚举练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson1__枚举练习
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson1_ 枚举练习/Program.cs b/C#基础/Lesson1_ 枚举练习/Program.cs
new file mode 100644
index 0000000..6aed71e
--- /dev/null
+++ b/C#基础/Lesson1_ 枚举练习/Program.cs
@@ -0,0 +1,155 @@
+using System;
+namespace Lesson1_枚举练习
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 练习题一
+ try
+ {
+ Console.WriteLine("选择你的状态:\n1.在线 2.离线 3.忙碌 4.离开");
+ int input1 = int.Parse(Console.ReadLine());
+ E_chatStatus chatStatus = (E_chatStatus)input1;
+ switch (chatStatus)
+ {
+ case E_chatStatus.online:
+ Console.WriteLine("你选择了在线状态");
+ break;
+ case E_chatStatus.offline:
+ Console.WriteLine("你选择了离线状态");
+ break;
+ case E_chatStatus.busy:
+ Console.WriteLine("你选择了忙碌状态");
+ break;
+ case E_chatStatus.away:
+ Console.WriteLine("你选择了离开状态");
+ break;
+ default:
+ Console.WriteLine("无效的状态");
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("请输入正确的数字或名称");
+ Console.WriteLine("error code" + e);
+ throw;
+ }
+ #endregion
+ Console.WriteLine("press any key to continue");
+
+ int block = Console.ReadKey().KeyChar;
+ Console.Clear();
+ #region 练习题二
+ try
+ {
+ Console.WriteLine("请你选择需要购买的咖啡:\n1.中杯medium 2.大杯large 3.特大杯extralarge");
+ string input2 = Console.ReadLine();
+ E_menu menu = (E_menu)Enum.Parse(typeof(E_menu), input2);
+
+ switch (menu)
+ {
+ case E_menu.medium:
+ Console.WriteLine("你选择了中杯咖啡,花费35");
+ break;
+ case E_menu.large:
+ Console.WriteLine("你选择了大杯咖啡,花费40");
+ break;
+ case E_menu.extralarge:
+ Console.WriteLine("你选择了特大杯咖啡,花费43");
+ break;
+ default:
+ Console.WriteLine("无效的选择");
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("请输入正确的数字或名称");
+ Console.WriteLine("Error code:"+e);
+ throw;
+ }
+ #endregion
+ Console.WriteLine("press any key to continue");
+ block = Console.ReadKey().KeyChar;
+ Console.Clear();
+ #region 练习题三
+ int Attack = 0, Defense = 0;
+ Console.WriteLine("请选择你的性别:\n1.男 2.女");
+ string input3 = Console.ReadLine();
+ E_sex sex = (E_sex)Enum.Parse(typeof(E_sex), input3);
+ Console.WriteLine("请你选择你的职业:\n1.战士 2.猎人 3.法师");
+ input3 = Console.ReadLine();
+ E_career career = (E_career)Enum.Parse(typeof(E_career), input3);
+ E_skill skill = E_skill.ArcaneBlast;
+ switch (sex)
+ {
+ case E_sex.male:
+ Attack += 50;
+ Defense += 100;
+ break;
+ case E_sex.female:
+ Attack += 150;
+ Defense += 20;
+ break;
+ default:
+ break;
+ }
+ switch (career)
+ {
+ case E_career.warrior:
+ Attack += 20;
+ Defense += 100;
+ skill = E_skill.Push;
+ break;
+ case E_career.hunter:
+ Attack += 120;
+ Defense += 30;
+ skill = E_skill.PlayDead;
+ break;
+ case E_career.mage:
+ Attack += 200;
+ Defense += 10;
+ skill = E_skill.ArcaneBlast;
+ break;
+ default:
+ break;
+ }
+ Console.WriteLine("You are "+sex+" "+career+",Attack:"+Attack+",Defense:"+Defense+",CareerSkill:" + skill);
+ #endregion
+ }
+ }
+ enum E_chatStatus
+ {
+ online = 1,
+ offline = 2,
+ busy = 3,
+ away = 4
+ }
+
+ enum E_menu
+ {
+ medium = 1,
+ large = 2,
+ extralarge = 3
+ }
+
+ enum E_sex
+ {
+ male = 1,
+ female = 2
+ }
+ enum E_career
+ {
+ warrior = 1,
+ hunter = 2,
+ mage = 3
+ }
+ enum E_skill
+ {
+ Push = 1,
+ PlayDead = 2,
+ ArcaneBlast = 3
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson1_枚举/Lesson1_枚举.csproj b/C#基础/Lesson1_枚举/Lesson1_枚举.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson1_枚举/Lesson1_枚举.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson1_枚举/Program.cs b/C#基础/Lesson1_枚举/Program.cs
new file mode 100644
index 0000000..ab2f223
--- /dev/null
+++ b/C#基础/Lesson1_枚举/Program.cs
@@ -0,0 +1,116 @@
+using System;
+#region 知识点二 在哪里声明枚举
+// 1.在namespace中声明枚举(常用)
+// 2.在class中声明枚举
+// 3.在struct中声明枚举
+// 注意:枚举不能在函数,方法中声明
+#endregion
+namespace 枚举
+{
+ #region 知识点一 基本概念
+
+ #region 1枚举是什么
+ //枚举是一个比较特别的存在
+ //他是一个被命名的整形常量的集合
+ //一般用它来表示 状态 类型 等等
+ #endregion
+
+ #region 2声明枚举 和 声明枚举变量
+ //注意:声明枚举 和 声明枚举变量 是两回事
+ //声明枚举: 相当于是 闯将一个自定义的枚举类型
+ //声明枚举变量: 使用声明的自行定义枚举类型 创建一个枚举变量
+ #endregion
+
+ #region 3声明枚举语法
+ // enum 枚举名
+ // 一般来说,枚举名以E或E_开头,作为一种默认的规范
+ //enum E_自定义枚举名
+ //{
+ // 自定义枚举项名字,// 这里是枚举中包裹的 整形常量 第一个默认值是0 下面会依次累加
+ // 自定义枚举项名字1,// 1
+ // 自定义枚举项名字2,// 2
+ //}
+ enum E_自定义枚举名
+ {
+ 自定义枚举项名字 = 5,// 第一个默认值是5 下面会依次累加
+ 自定义枚举项名字1,// 这里会是6
+ 自定义枚举项名字2 = 100,// 改变默认值为100 下面还会依次累加
+ }
+ #endregion
+
+ #endregion
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点三 枚举的使用
+ //例子-声明枚举变量
+ E_PlayerType playerType = E_PlayerType.Hunter;
+
+ if(playerType == E_PlayerType.Warlock)
+ {
+ Console.WriteLine("玩家是术士");
+ }
+ else if (playerType == E_PlayerType.Titan)
+ {
+ Console.WriteLine("玩家是泰坦");
+ }
+ else if (playerType == E_PlayerType.Hunter)
+ {
+ Console.WriteLine("玩家是猎人");
+ }
+ //枚举和switch非常配合
+ //甚至可以自动补全
+ E_MonsterType monsterType = E_MonsterType.Boss;
+ switch (monsterType)
+ {
+ case E_MonsterType.Normal:
+ Console.WriteLine("普通怪物的功能");
+ break;
+ case E_MonsterType.Boss:
+ Console.WriteLine("BOSS怪物的功能");
+ break;
+ default:
+ break;
+ }
+
+ #endregion
+
+ #region 知识点四 枚举的类型转换
+ //1.枚举和int互转
+ int i = (int)playerType;
+ Console.WriteLine(i);
+ //2.枚举和string互转
+ string str = playerType.ToString();
+ Console.WriteLine(str);
+
+ //3.字符串转枚举
+ //(括号强转写目标枚举类型)Enum.Parse(typeof(同样目标枚举类型), "完全一致的字符串");
+ playerType = (E_PlayerType)Enum.Parse(typeof(E_PlayerType), "Titan");
+ Console.WriteLine(playerType);
+ #endregion
+
+ #region 知识点五 枚举的作用
+ //在游戏开发中,对象很多的时候,会有很多状态
+ //比如玩家的动作状态,我们需要用变量或某种标识来表示玩家处于的是哪种状态
+ //如果用int来表示状态,数字的含义就不明确了
+ //如果用枚举来表示状态,枚举的名字就能清晰地表达出状态的含义
+ #endregion
+ }
+ }
+ #region 例子-声明枚举
+ enum E_MonsterType
+ {
+ Normal,
+ Boss,
+ }
+ enum E_PlayerType
+ {
+ Titan,
+ Warlock,
+ Hunter,
+ }
+ #endregion
+}
+
+
diff --git a/C#基础/Lesson2_一维数组/Lesson2_一维数组.csproj b/C#基础/Lesson2_一维数组/Lesson2_一维数组.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson2_一维数组/Lesson2_一维数组.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson2_一维数组/Program.cs b/C#基础/Lesson2_一维数组/Program.cs
new file mode 100644
index 0000000..3d7a691
--- /dev/null
+++ b/C#基础/Lesson2_一维数组/Program.cs
@@ -0,0 +1,130 @@
+using System;
+namespace Lesson2_一维数组
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点一 基本概念
+ //数组是存储一组相同类型数据的集合
+ //数组分为 一维、多位、交错数组
+ //一般情况分为 一维数组 简称为数组
+ #endregion
+
+ #region 知识点二 数组的声明
+ //数组的声明
+ // 变量类型[] 数组名; //只是声明了数组,没有分配内存空间
+ int[] arr1; //声明了一个整型数组变量arr1,但没有分配内存空间
+
+ // 变量类型[] 数组名 = new 变量类型[长度]; //声明并分配内存空间
+ int[] arr2 = new int[5]; //声明并分配了一个长度为5的整型数组arr2,
+ //此时数组中的每个元素都被初始化为默认值0
+
+ // 变量类型[] 数组名 = new 变量类型[长度] { 元素1, 元素2, ... }; //声明并初始化数组
+ int[] arr3 = new int[5] { 1, 2, 3, 4, 5 }; //声明并初始化了一个长度为5的整型数组arr3
+
+ // 变量类型[] 数组名 = new 变量类型[] { 元素1, 元素2, ... }; //声明并初始化数组,长度由元素个数决定
+ int[] arr4 = new int[] { 1, 2, 3, 4, 5 }; //声明并初始化了一个整型数组arr4,长度由元素个数决定
+
+ // 变量类型[] 数组名 = { 元素1, 元素2, ... }; //声明并初始化数组,长度由元素个数决定
+ int[] arr5 = { 1, 2, 3, 4, 5 }; //声明并初始化了一个整型数组arr5,长度由元素个数决定
+ #endregion
+
+ #region 知识点三 数组的使用
+ int[] array = { 1, 2, 3, 4, 5 };
+ //1.数组的长度可以用变量.Length获取
+ Console.WriteLine(array.Length);
+ Console.ReadKey();
+ Console.Clear();
+
+
+
+ //2.数组的下标和索引是从0开始的
+ //注意:访问数组时,索引不能越界,范围在0到Length-1之间
+ Console.WriteLine(array[0]);//1
+ Console.WriteLine(array[4]);//5
+ Console.ReadKey();
+ Console.Clear();
+
+
+
+ //3.修改数组中的元素
+ array[0] = 10;
+ Console.WriteLine(array[0]);
+ Console.ReadKey();
+ Console.Clear();
+
+
+
+ //4.遍历数组
+ for (int i = 0; i < array.Length; i++)
+ {
+ Console.WriteLine(array[i]);
+ }
+ Console.ReadKey();
+ Console.Clear();
+
+
+
+ //5.增加数组的元素
+ //数组的长度是固定的,不能动态增加
+ //如果需要增加数组的元素,可以创建一个新的数组,将旧数组的元素复制到新数组中
+ int[] newArray = new int[array.Length + 1];
+ //迁移数组
+ for (int i = 0; i < array.Length; i++)
+ {
+ newArray[i] = array[i];
+ }
+ //给新数组的最后一个元素赋值
+ newArray[newArray.Length - 1] = 6;
+ //让array引用newArray
+ array = newArray;
+ for (int i = 0; i < array.Length; i++)
+ {
+ Console.WriteLine(array[i]);
+ }
+ Console.WriteLine("数组长度:" + array.Length);
+ Console.ReadKey();
+ Console.Clear();
+
+
+
+ //6.删除数组的元素
+ //数组的长度是固定的,不能动态删除
+ //如果需要删除数组的元素,可以创建一个新的数组,将旧数组的元素复制到新数组中
+ int[] newArray2 = new int[array.Length - 1];//这里假设删除的是最后一个元素,
+ //如果删除的是其他元素,需要调整索引
+ //迁移数组
+ for (int i = 0; i < newArray2.Length; i++)
+ {
+ newArray2[i] = array[i];
+ }
+ //让array引用newArray2
+ array = newArray2;
+ for (int i = 0; i < array.Length; i++)
+ {
+ Console.WriteLine(array[i]);
+ }
+ Console.WriteLine("数组长度:" + array.Length);
+ Console.ReadKey();
+ Console.Clear();
+
+ //7.查找数组中的元素
+ //可以使用循环遍历数组,查找指定元素
+ Console.WriteLine("请输入要查找的数");
+ int num = int.Parse(Console.ReadLine());//注意不能使用console.read
+
+
+
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (array[i] == num)
+ {
+ Console.WriteLine($"找到了{num},索引为{i}");
+ break;
+ }
+ }
+ #endregion
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson2_数组练习/Lesson2_一维数组练习.csproj b/C#基础/Lesson2_数组练习/Lesson2_一维数组练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson2_数组练习/Lesson2_一维数组练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson2_数组练习/Program.cs b/C#基础/Lesson2_数组练习/Program.cs
new file mode 100644
index 0000000..2725e78
--- /dev/null
+++ b/C#基础/Lesson2_数组练习/Program.cs
@@ -0,0 +1,199 @@
+#region 练习题一
+int[] array = new int[100];
+for (int i = 0; i < array.Length; i++)
+{
+ array[i] = i;
+ Console.Write(array[i] + " ");
+}
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+
+#region 练习题二
+int[] array2 = new int[100];
+for (int i = 0; i < array2.Length; i++)
+{
+ array2[i] = array[i]*2;
+ Console.Write(array2[i] + " ");
+}
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+
+#region 练习题三
+int[] array3 = new int[100];
+Random r = new Random();
+for (int i = 0; i < array3.Length; i++)
+{
+ array3[i] = r.Next(0,101);
+ Console.Write(array3[i] + " ");
+}
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+
+#region 练习题四
+int[] array4 = new int[100];
+int max=0, min=100, sum=0, avg=0;
+for (int i = 0; i < array4.Length; i++)
+{
+ array4[i] = r.Next(0, 101);
+ if(max < array4[i])
+ {
+ max = array4[i];
+ }
+ if(min > array4[i])
+ {
+ min = array4[i];
+ }
+ sum += array4[i];
+ avg = sum / array4.Length;
+ Console.Write(array4[i] + " ");
+}
+Console.WriteLine();
+Console.WriteLine($"最大值为:{max}");
+Console.WriteLine($"最小值为:{min}");
+Console.WriteLine($"总和为:{sum}");
+Console.WriteLine($"平均值为:{avg}");
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+
+#region 练习题五
+int[] array5 = new int[10];
+for (int i = 0; i < array5.Length; i++)
+{
+ array5[i] = r.Next(0, 101);
+ Console.Write(array5[i] + " ");
+}
+//反转
+int temp;
+for (int i = 0; i < array5.Length / 2; i++)
+{
+ temp = array5[i];
+ array5[i] = array5[array5.Length - 1 - i];
+ array5[array5.Length - 1 - i] = temp;
+
+}
+Console.WriteLine();
+Console.WriteLine("反转后:");
+for (int i = 0; i < array5.Length; i++)
+{
+ Console.Write(array5[i] + " ");
+}
+Console.WriteLine();
+Console.WriteLine("反打反转:");
+for (int i = array5.Length - 1; i >= 0; i--)
+{
+ Console.Write(array5[i] + " ");
+}
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+
+#region 练习题六
+int[] array6 = new int[10];
+for (int i = 0; i < array6.Length; i++)
+{
+ array6[i] = r.Next(-10, 11);
+ Console.Write(array6[i] + " ");
+}
+for (int i = 0;i < array6.Length; i++)
+{
+ if (array6[i] < 0)
+ {
+ array6[i] -= 1;
+ }
+ else if (array6[i] > 0)
+ {
+ array6[i] += 1;
+ }
+}
+Console.WriteLine();
+Console.WriteLine("处理后:");
+for (int i = 0; i < array6.Length; i++)
+{
+ Console.Write(array6[i] + " ");
+}
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+
+#region 练习题七
+int[] array7 = new int[10];
+try
+{
+ for (int i = 0; i < array7.Length; i++)
+ {
+ Console.Write($"请输入第{i + 1}位同学的成绩:");
+ array7[i] = int.Parse(Console.ReadLine());
+
+ }
+}
+catch
+{
+ Console.WriteLine("输入错误,请输入数字!");
+ return;
+}
+max = array7[0];
+min = array7[0];
+sum = 0;
+avg = 0;
+for (int i = 0; i < array7.Length; i++)
+{
+ if (max < array7[i])
+ {
+ max = array7[i];
+ }
+ if (min > array7[i])
+ {
+ min = array7[i];
+ }
+ sum += array7[i];
+}
+avg = sum / array7.Length;
+Console.WriteLine($"成绩最高成绩为{max}");
+Console.WriteLine($"成绩最低成绩为{min}");
+Console.WriteLine($"成绩总和成绩为{sum}");
+Console.WriteLine($"平均成绩成绩为{avg}");
+for (int i = 0; i < array7.Length; i++)
+{
+ if (array7[i] >= 60)
+ {
+ Console.WriteLine($"第{i + 1}位同学成绩为:{array7[i]},成绩合格");
+ }
+ else
+ {
+ Console.WriteLine($"第{i + 1}位同学成绩为:{array7[i]},成绩不合格");
+ }
+}
+#endregion
+
+
+#region 练习题八
+string[] array8 = new string[25];
+for (int i = 0; i < array8.Length; i++)
+{
+ //if (i % 2 == 0)
+ //{
+ // array8[i] = "■";
+ //}
+ //else
+ //{
+ // array8[i] = "□";
+ //}
+ array8[i] = i % 2 == 0 ? "■" : "□";//无敌
+ //打印
+ Console.Write(array8[i]);
+ if ((i + 1) % 5 == 0)
+ {
+ Console.WriteLine();
+ }
+}
+#endregion
\ No newline at end of file
diff --git a/C#基础/Lesson3_二维数组/Lesson3_二维数组.csproj b/C#基础/Lesson3_二维数组/Lesson3_二维数组.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson3_二维数组/Lesson3_二维数组.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson3_二维数组/Program.cs b/C#基础/Lesson3_二维数组/Program.cs
new file mode 100644
index 0000000..adf1f1e
--- /dev/null
+++ b/C#基础/Lesson3_二维数组/Program.cs
@@ -0,0 +1,171 @@
+#region 知识点一 基本概念
+//二维数组 是使用两个索引来引用的数组。
+//它可以看作是一个表格,有行和列。
+//可以用来表示矩阵、棋盘等二维数据结构。
+//
+#endregion
+
+#region 知识点二 声明和初始化
+//1.变量类型[,] 变量名;
+int[,] arr1;//声明后必须初始化
+
+//2.变量类型[,] 变量名 = new 变量类型[行数, 列数];
+int[,] arr2 = new int[2, 3];//声明并初始化,默认值为0
+//二维数组的行数和列数必须是常量表达式,不能是变量。
+
+//3.变量类型[,] 变量名 = { {元素1, 元素2}, {元素3, 元素4} };
+int[,] arr3 = { { 1, 2 }, { 3, 4 } };//声明并初始化
+
+//4.变量类型[,] 变量名 = new 变量类型[行数, 列数] { {元素1, 元素2}, {元素3, 元素4} };
+int[,] arr4 = new int[2, 2] { { 1, 2 },
+ { 3, 4 } };//声明并初始化
+
+//5.变量类型[,] 变量名 = new 变量类型[,] { {元素1, 元素2}, {元素3, 元素4} };
+int[,] arr5 = new int[,] { { 1, 2 },
+ { 3, 4 } };//声明并初始化
+
+#endregion
+
+#region 知识点三 二维数组的使用
+//1.二维数组的长度
+Console.WriteLine("二维数组的长度");
+int[,] array = new int[,] { { 1, 2, 3 },
+ { 4, 5, 6 } };
+//二维数组的长度可以分为行数,列数和总元素个数
+//获取二维数组的第0维长度(行数)
+Console.WriteLine(array.GetLength(0));
+//获取二维数组的第1维长度(列数)
+Console.WriteLine(array.GetLength(1));
+
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+//2.获取二维数组中的元素
+Console.WriteLine("获取二维数组中的元素");
+//注意:第一个元素是0行0列,最后一个元素是(行数-1)列(列数-1)
+Console.WriteLine(array[0, 0]);//1
+Console.WriteLine(array[1, 2]);//6
+
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+//3.修改二维数组中的元素
+Console.WriteLine("修改二维数组中的元素");
+array[0, 0] = 10;
+Console.WriteLine(array[0, 0]);//10
+
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+//4.遍历二维数组
+Console.WriteLine("遍历二维数组");
+for (int i =0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array.GetLength(1); j++)
+ {
+ Console.Write(array[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+//5.增加数组的元素
+Console.WriteLine("增加数组的元素");
+//二维数组的大小是固定的,不能动态增加元素。
+//如果需要增加元素,可以创建一个新的二维数组,并将原数组的元素复制到新数组中。
+int newRow = array.GetLength(0) + 1;
+int newCol = array.GetLength(1);
+int[,] newArray = new int[newRow, newCol];
+
+for (int i = 0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array.GetLength(1); j++)
+ {
+ newArray[i, j] = array[i, j];
+ }
+}
+array = newArray;
+array[2, 0] = 7;
+array[2, 1] = 8;
+array[2, 2] = 9;
+for (int i = 0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array.GetLength(1); j++)
+ {
+ Console.Write(array[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+//6.删除数组的元素
+Console.WriteLine("删除数组的元素");
+//二维数组的大小是固定的,不能动态删除元素。
+//如果需要删除元素,可以创建一个新的二维数组,并将原数组的元素复制到新数组中,跳过要删除的元素。
+newRow = array.GetLength(0)-1;
+newCol = array.GetLength(1);
+newArray = new int[newRow, newCol];
+Console.WriteLine($"原数组行数{array.GetLength(0)}\t原数组列数{array.GetLength(1)}");
+Console.WriteLine($"新组行数{newArray.GetLength(0)}\t新组列数{newArray.GetLength(1)}");
+Console.WriteLine("打印原数组:");
+for (int i = 0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array.GetLength(1); j++)
+ {
+ Console.Write(array[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+//假设删除第2行
+for (int i = 0; i < newArray.GetLength(0); i++)
+{
+ for (int j = 0; j < newArray.GetLength(1); j++)
+ {
+ newArray[i, j] = array[i, j];
+ }
+}
+array = newArray;//引用新数组
+Console.WriteLine("打印新数组:");
+for (int i = 0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array.GetLength(1); j++)
+ {
+ Console.Write(array[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+
+//7.查找数组中的元素
+Console.WriteLine("查找数组中的元素");
+//如果要在数组中查找某个元素,可以使用循环遍历数组,逐个比较元素值。
+//找到后可以记录下标或者直接返回元素。
+for (int i = 0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array.GetLength(1); j++)
+ {
+ if (array[i, j] == 5)
+ {
+ Console.WriteLine($"找到了元素5,位置在:{i}行{j}列");
+ }
+ }
+}
+#endregion
\ No newline at end of file
diff --git a/C#基础/Lesson3_二维数组练习题/Lesson3_二维数组练习题.csproj b/C#基础/Lesson3_二维数组练习题/Lesson3_二维数组练习题.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson3_二维数组练习题/Lesson3_二维数组练习题.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson3_二维数组练习题/Program.cs b/C#基础/Lesson3_二维数组练习题/Program.cs
new file mode 100644
index 0000000..d20821c
--- /dev/null
+++ b/C#基础/Lesson3_二维数组练习题/Program.cs
@@ -0,0 +1,180 @@
+#region 练习题一
+int[,] arr1 = new int[100, 100];
+int index = 1;
+for (int i = 0; i < arr1.GetLength(0); i++)
+{
+ for (int j = 0; j < arr1.GetLength(1); j++)
+ {
+ arr1[i, j] = index;
+ ++index;
+ }
+}
+for (int i = 0; i < arr1.GetLength(0); i++)
+{
+ for (int j = 0; j < arr1.GetLength(1); j++)
+ {
+ Console.Write(arr1[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+#endregion
+
+#region 练习题二
+Console.WriteLine("练习题二");
+int[,] arr2 = new int[6, 6];
+Random r = new Random();
+Console.WriteLine(arr2.GetLength(0) / 2 + " " + arr2.GetLength(1) / 2);
+for (int i = 0; i < arr2.GetLength(0); i++)
+{
+ for (int j = 0; j < arr2.GetLength(1); j++)
+ {
+ if (i < arr2.GetLength(0)/2 && j+1 > arr2.GetLength(1)/2)
+ arr2[i, j] = 0;
+ else
+ arr2[i, j] = r.Next(1, 11);
+ }
+}
+for (int i = 0; i < arr2.GetLength(0); i++)
+{
+ for (int j = 0; j < arr2.GetLength(1); j++)
+ {
+ Console.Write(arr2[i, j] + "\t");//+" "+ i + j +
+ }
+ Console.WriteLine();
+}
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+#endregion
+
+#region 练习题三
+Console.WriteLine("练习题三");
+int[,] arr3 = new int[3, 3];
+int sum = 0;
+for (int i = 0; i < arr3.GetLength(0); i++)
+{
+ for (int j = 0; j < arr3.GetLength(1); j++)
+ {
+ arr3[i, j] = r.Next(1,11);
+ if (i == j)
+ sum += arr3[i, j];
+ }
+}
+for (int i = 0; i < arr3.GetLength(0); i++)
+{
+ for (int j = 0; j < arr3.GetLength(1); j++)
+ {
+ Console.Write(arr3[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+Console.WriteLine(sum);
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+#endregion
+
+#region 练习题四
+Console.WriteLine("练习题四");
+int[,] arr4 = new int[3, 3];
+sum = 0;
+for (int i = 0; i < arr4.GetLength(0); i++)
+{
+ for (int j = 0; j < arr4.GetLength(1); j++)
+ {
+ arr4[i, j] = r.Next(1, 11);
+ if (i == j)
+ sum += arr4[i, j];
+ else if (i + j == arr4.GetLength(1) - 1)
+ sum += arr4[i, j];
+ }
+}
+for (int i = 0; i < arr4.GetLength(0); i++)
+{
+ for (int j = 0; j < arr4.GetLength(1); j++)
+ {
+ Console.Write(arr4[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+Console.WriteLine(sum);
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+#endregion
+
+#region 练习题五
+Console.WriteLine("练习题五");
+int[,] arr5 = new int[5, 5];
+int max = 0;
+int min = 11;
+for (int i = 0; i < arr5.GetLength(0); i++)
+{
+ for (int j = 0; j < arr5.GetLength(1); j++)
+ {
+ arr5[i, j] = r.Next(1,11);
+ if (arr5[i, j] > max)
+ max = arr5[i, j];
+ if (arr5[i, j] < min)
+ min = arr5[i, j];
+ }
+}
+for (int i = 0; i < arr5.GetLength(0); i++)
+{
+ for (int j = 0; j < arr5.GetLength(1); j++)
+ {
+ Console.Write(arr5[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+Console.WriteLine(max);
+Console.WriteLine(min);
+#region clear
+Console.ReadKey();
+Console.Clear();
+#endregion
+#endregion
+
+#region 练习题六
+Console.WriteLine("练习题六");
+int m = 5, n = 5;
+int[,] arr6 = new int[m, n];
+//bool类型的数组默认值是false,所以可以用来标记某个位置是否被访问过
+bool[] hang = new bool[m];
+bool[] lie = new bool[n];
+for (int i = 0; i < arr6.GetLength(0); i++)
+{
+ for (int j = 0; j < arr6.GetLength(1); j++)
+ {
+ arr6[i, j] = r.Next(0, 2);
+ Console.Write(arr6[i, j] + "\t");
+ if (arr6[i, j] == 1)
+ {
+ hang[i] = true;
+ lie[j] = true;
+ }
+ }
+ Console.WriteLine();
+}
+Console.WriteLine("分割");
+for (int i = 0; i < arr6.GetLength(0); i++)
+{
+ for (int j = 0; j < arr6.GetLength(1); j++)
+ {
+ if (hang[i] == true || lie[j] == true)
+ {
+ arr6[i, j] = 1;
+ }
+ Console.Write(arr6[i, j] + "\t");
+ }
+ Console.WriteLine();
+}
+
+#endregion
\ No newline at end of file
diff --git a/C#基础/Lesson4_交错数组/Lesson4_交错数组.csproj b/C#基础/Lesson4_交错数组/Lesson4_交错数组.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson4_交错数组/Lesson4_交错数组.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson4_交错数组/Program.cs b/C#基础/Lesson4_交错数组/Program.cs
new file mode 100644
index 0000000..7cc9a3c
--- /dev/null
+++ b/C#基础/Lesson4_交错数组/Program.cs
@@ -0,0 +1,58 @@
+#region 知识点一 基本概念
+//交错数组 是 数组的数组,每个维度的数量可以不同
+//注意:二维数组的每行的列数相同,交错数组每行的列数可能不同
+//一般情况下都用于行列数不一的情况
+#endregion
+
+#region 知识点二 数组的声明
+//1.变量类型[][] 交错数组名;
+int[][] arr1;
+
+//2.变量类型[][] 交错数组名 = new 变量类型[行数][];
+int[][] arr2 = new int[3][];
+
+//3.变量类型[][] 交错数组名 = new 变量类型[行数][]{一维数组,一维数组2,......};
+int[][] arr3 = new int[3][] { new int[] {1,2,3 },
+ new int[] {1,2},
+ new int[] {1,2,3 }
+ };
+//4.变量类型[][] 交错数组名 = new 变量类型[][]{一维数组,一维数组2,......};
+int[][] arr4 = new int[][] { new int[] {1,2,3 },
+ new int[] {1,2},
+ new int[] {1,2,3 }
+ };
+//5.变量类型[][] 交错数组名 = {一维数组,一维数组2,......};
+int[][] arr5 = { new int[] {1,2,3 },
+ new int[] {1,2},
+ new int[] {1,2,3 }
+ };
+#endregion
+
+#region 知识点三 数组的使用
+int[][] array = { new int[] { 1,2,3},
+ new int[] {4,5}
+ };
+//1.数组长度
+//行
+Console.WriteLine(array.GetLength(0));
+//列(得到某一行的列数
+Console.WriteLine(array[0].Length);
+
+//2.获取交错数组中的元素(注意别越界
+Console.WriteLine(array[0][1]);
+
+//3.修改元素(同上
+array[0][1] = 99;
+
+//4.遍历
+for (int i = 0; i < array.GetLength(0); i++)
+{
+ for (int j = 0; j < array[i].Length; j++)
+ {
+ Console.Write(array[i][j]+"\t");
+ }
+ Console.WriteLine();
+}
+
+//5.增删查(懒得写)
+#endregion
\ No newline at end of file
diff --git a/C#基础/Lesson5_值类型和引用类型/Lesson5_值类型和引用类型.csproj b/C#基础/Lesson5_值类型和引用类型/Lesson5_值类型和引用类型.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson5_值类型和引用类型/Lesson5_值类型和引用类型.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson5_值类型和引用类型/Program.cs b/C#基础/Lesson5_值类型和引用类型/Program.cs
new file mode 100644
index 0000000..5c828b2
--- /dev/null
+++ b/C#基础/Lesson5_值类型和引用类型/Program.cs
@@ -0,0 +1,63 @@
+#region 知识点一 变量类型的复习
+//无符号整形
+//byte b = 1;
+//ushort us = 1;
+//uint ui = 1;
+//ulong ul = 1;
+
+//有符号整形
+//sbyte sb = -1;
+//short s = -1;
+//int i = -1;
+//long l = -1;
+
+//浮点型
+//float f = 1f;
+//double d = 1.1;
+//decimal dec = 1.1m;
+
+//特殊类型
+//bool bo = true;
+//char c = 'a';
+//string str = "string";
+
+//复杂类型
+//enum 枚举
+//数组(一维、二维、交错)
+
+//把以上 学过的变量类型 分成 值类型和引用类型
+//引用类型:string,数组,类(未学习)
+//值类型:其他、结构体(未学习)
+#endregion
+
+#region 知识点二 值类型和引用类型的区别
+//1.使用上的区别
+//值类型
+int a = 10;
+//引用类型
+int[] arr = new int[] { 1, 2, 3, 4 };
+
+
+//声明了一个b让其等于之前的a
+int b = a;
+//声明了一个arr2让其等于之前的arr
+int[] arr2 = arr;
+Console.WriteLine("a={0},b={1}",a,b);
+Console.WriteLine("arr[0]={0},arr2[0]={1}", arr[0], arr2[0]);
+
+b = 20;
+arr2[0] = 5;
+Console.WriteLine("修改了b和arr2[0]后:");
+Console.WriteLine("a={0},b={1}", a, b);
+Console.WriteLine("arr[0]={0},arr2[0]={1}", arr[0], arr2[0]);
+
+//值类型 在相互赋值时,是将值进行复制,互不影响,他变我不变
+
+//引用类型 在相互赋值时,是将地址进行复制,互相关联,他变我也变
+
+//2.为什么有以上区别
+//值类型和应用类型 存储在的内存区域是不同的 存储方式是不同的
+//值类型 直接存储在 栈内存 中 -- 系统分配,自动回收,小而快
+//引用类型 变量本身存储在 栈内存 中,实际数据存储在 堆内存 中 -- 手动分配,手动回收,大而慢
+//string虽然也是引用类型 但它有值类型的特性,因为它不可变
+#endregion
\ No newline at end of file
diff --git a/C#基础/Lesson6_特殊的引用类型string/Lesson6_特殊的引用类型string.csproj b/C#基础/Lesson6_特殊的引用类型string/Lesson6_特殊的引用类型string.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson6_特殊的引用类型string/Lesson6_特殊的引用类型string.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson6_特殊的引用类型string/Program.cs b/C#基础/Lesson6_特殊的引用类型string/Program.cs
new file mode 100644
index 0000000..5351f55
--- /dev/null
+++ b/C#基础/Lesson6_特殊的引用类型string/Program.cs
@@ -0,0 +1,35 @@
+#region 知识点一 复习值和引用类型
+// 值类型-他变我不变,存储在栈内存中
+// 无符号整形,有符号整形,浮点数,char,bool,结构体,enum
+
+// 引用类型-他变我也变,存储在堆内存中
+// string,数组,类
+#endregion
+
+#region 知识点二 string类型的特殊性
+string str1 = "123";
+string str2 = str1;
+//因为string是引用类型,所以str2和str1应该是指向同一个地址的
+str2 = "321";
+Console.WriteLine(str1);
+Console.WriteLine(str2);
+//但是输出结果是str1=123,str2=321
+//原因:string类型是不可变类型
+//修改,或重新给string类型赋值时,重新开辟了一块堆内存空间来存储新的值
+//当str2重新指回"123"时,str2和str1才会指向同一个地址
+//但是堆内存中原来存储"321"没被引用,就变成了垃圾,等待垃圾回收器来回收
+
+//所以string会有优化替代的方案(后面教)
+#endregion
+
+#region 补充知识点 断点调试
+//通过断点调试 在监视窗口中查看内存信息
+//断点:窗口最左侧红点
+//调试->窗口->监视
+//F10逐步执行
+string str4 = "123";
+string str5 = str1;
+str5 = "321";
+Console.WriteLine(str4);
+Console.WriteLine(str5);
+#endregion
\ No newline at end of file
diff --git a/C#基础/Lesson7_函数/Lesson7_函数.csproj b/C#基础/Lesson7_函数/Lesson7_函数.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson7_函数/Lesson7_函数.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson7_函数/Program.cs b/C#基础/Lesson7_函数/Program.cs
new file mode 100644
index 0000000..0f69058
--- /dev/null
+++ b/C#基础/Lesson7_函数/Program.cs
@@ -0,0 +1,138 @@
+using System;
+namespace Lesson7_函数
+{
+ class Program
+ {
+ #region 知识点一 基本概念
+ //函数(方法)
+ //本质是一块具有名称的代码块
+ //可以使用函数(方法)的名称来调用它
+ //函数(方法)是封装代码进行重复使用的手段
+
+ //函数(方法)的主要作用
+ //1.封装代码
+ //2.提高代码的复用性
+ //3.抽象行为
+ #endregion
+
+ #region 知识点二 函数写在哪里
+ //1.class类里面
+ //2.struct结构体里面
+ #endregion
+
+ #region 知识点三 基本语法
+ //4个部分
+ // 1 2 3 4
+ // static 返回类型 函数名(参数类型 参数名1,参数类型 参数名2.......)
+ // {
+ // 函数体(代码)
+ // 5(可选,根据返回类型)
+ // return 返回值;
+ // }
+
+ //1 static
+ //不是必须的 在没有学习类和结构体之前 先统一写上
+ //2.1 返回类型
+ //void 表示没有返回值
+ //返回类型可以是任何数据类型 14种变量类型+复杂数据类型(数组、枚举、结构体)
+ //3 函数名
+ //使用帕斯卡命名法(PascalCase) 每个单词首字母大写
+ //4.1 参数列表
+ //不是必须的,可以没有参数 多个参数时,使用逗号间隔 参数类型也可以是任何数据类型
+ //4.2 参数的命名
+ //使用驼峰命名法(camelCase) 第一个单词首字
+ //5 return
+ //当返回类型不是void时 必须使用return语句 来返回一个与返回类型匹配的值
+ //void也可以使用return 但不能返回任何值 只能单独使用return来结束函数
+ #endregion
+
+ #region 知识点四 实际运用
+ //1.无参无返回值
+ static void SayHello()
+ {
+ Console.WriteLine("Hello World");
+ //return; //可选
+ }
+
+ //2.有参无返回值
+ static void SayYourName(string name)
+ {
+ Console.WriteLine("Hello " + name);
+ }
+ //3.无参有返回值
+ static string WhatsYourName()
+ {
+ return "王五";
+ }
+ //4.有参有返回值
+ static int Sum(int a,int b)
+ {
+ return a + b;//return后面可以是一个表达式
+ }
+ //5.有参有返回值(多个参数)
+ //函数的返回值只能有一个,多个返回值时,可以使用数组、结构体、类等复杂数据类型来实现
+ static float[] AverageAndSum(int a, int b)
+ {
+ int sum = a + b;
+ float avg = (a + b) / 2.0f;
+ return new float[] { sum, avg};
+ }
+
+ #endregion
+
+ #region 知识点五 关于return
+ //即使函数没有返回值,也可以使用return
+ //return可以直接不执行return后的代码,直接结束函数
+ static void Speek(string str)
+ {
+ if (str == "脏话")
+ {
+ return;
+ }
+ else
+ {
+ Console.WriteLine(str);
+ }
+ }
+ #endregion
+ static void Main(string[] args)
+ {
+ //调用函数
+ //函数名(参数);
+ SayHello();
+ Console.WriteLine();
+
+ //传入一个string类型的参数
+ string str = "张三";
+ SayYourName(str);
+ //直接传入一个string类型的值
+ SayYourName("李四");
+ Console.WriteLine();
+
+ //接收WhatsYourName的返回值并传入SayYourName
+ SayYourName(WhatsYourName());
+ Console.WriteLine();
+
+ //一般来说
+ //有返回值的函数 直接拿返回值使用 或 拿变量接收返回值
+ string str2 = WhatsYourName();
+
+ //也可以直接调用,但没有任何意义
+ WhatsYourName();
+
+ //传入两个int类型的参数 让Sum函数运算 并接打印返回值
+ Console.WriteLine(Sum(10, 20));
+ Console.WriteLine();
+
+ float[] arr = AverageAndSum(5, 7);
+ Console.WriteLine("sum" + arr[0] + "\t" + "avg" + arr[1]);
+ Console.WriteLine();
+
+ Console.WriteLine("return:");
+ Speek("脏话");//不会返回脏话
+ Console.WriteLine("不return");
+ Speek("好话");
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson7_函数练习/Lesson7_函数练习.csproj b/C#基础/Lesson7_函数练习/Lesson7_函数练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson7_函数练习/Lesson7_函数练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson7_函数练习/Program.cs b/C#基础/Lesson7_函数练习/Program.cs
new file mode 100644
index 0000000..f7d2624
--- /dev/null
+++ b/C#基础/Lesson7_函数练习/Program.cs
@@ -0,0 +1,85 @@
+using System;
+namespace Lesson7
+{
+ class Program
+ {
+ static int Compare(int a, int b)
+ {
+ int max = (a > b) ? a : b;
+ return max;
+ }
+
+ static float[] Circle(float r)
+ {
+ float pi = 3.14f;
+ float perimeter = 2 * pi * r;
+ float area = pi * (r * r);
+ return new float[] { perimeter, area };
+ }
+ static int[] ComplexCompare(int[] a)
+ {
+ int sum = 0, min = a[0],max = a[0],avg=0;
+ for (int i = 0; i < a.Length; i++)
+ {
+ sum += a[i];
+ if (a[i] > max)
+ {
+ max = a[i];
+ }
+ if (a[i] < min)
+ {
+ min = a[i];
+ }
+ }
+ avg = sum / a.Length;
+ return new int[] { sum, max, min, avg };
+ }
+ static bool Primenumber(int a)
+ {
+ for (int i = 2; i < a; i++)
+ {
+ if (a % i == 0)
+ return false;
+ }
+ return true;
+ }
+ static bool Year(int a)
+ {
+ if (a%400 == 0 || (a%4 == 0 && a%100 != 0))
+ {
+ return true;
+ }
+ return false;
+ }
+ static void Main(string[] arg)
+ {
+ Console.WriteLine("比较大小:");
+ Console.WriteLine(Compare(10, 20));
+
+ Console.WriteLine("圆:");
+ float[] circle = Circle(20);
+ Console.WriteLine("perimeter:" + circle[0] + " " + "area:" + circle[1]);
+
+ Console.WriteLine("综合:");
+ int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+ int[] result = ComplexCompare(x);
+ Console.WriteLine("总和:" + result[0] + "最大" + result[1] + "最小" + result[2] + "平均" + result[3]);
+
+ bool result2 = Primenumber(21);
+ if (result2)
+ {
+ Console.WriteLine("是质数");
+ }
+ else
+ {
+ Console.WriteLine("不是质数");
+ }
+
+ Console.WriteLine("闰年:");
+ Console.WriteLine(Year(2200));
+
+
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson8_ref和out/Lesson8_ref和out.csproj b/C#基础/Lesson8_ref和out/Lesson8_ref和out.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson8_ref和out/Lesson8_ref和out.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson8_ref和out/Program.cs b/C#基础/Lesson8_ref和out/Program.cs
new file mode 100644
index 0000000..52c7af3
--- /dev/null
+++ b/C#基础/Lesson8_ref和out/Program.cs
@@ -0,0 +1,144 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ #region 知识点一 学习ref和out的原因
+ //他们可以解决 在函数内部改变外部传入的内容 里面变了 外面也要变
+ #endregion
+
+
+
+
+
+ #region 知识点二 ref和out的使用
+ //函数参数的修饰符
+ //当传入的值类型参数在内部修改 或引用类型参数在内部重新声明时
+ //外部的值会发生变化
+ #endregion
+
+
+
+
+
+
+ #region 知识点三 ref和out的区别
+ //1.ref传入的变量必须在外部初始化,out不用
+ //2.out传入的变量必须在内部赋值,ref不用
+
+ //1
+ //int a;
+ //ChangeValueRef(ref a);//报错
+ //ChangeValueOut(out a);//不报错
+
+ //2
+ // static void ChangeValueOut(out int value)
+ // {
+ // value = 99;//不赋值报错
+ // }
+ #endregion
+
+
+
+
+
+
+
+ //ref(在函数类型参数前用ref修饰
+ static void ChangeValueRef(ref int value)
+ {
+ value = 99;
+ }
+ static void ChangeArrayRef(ref int[] arr)
+ {
+ arr = new int[] { 99, 99, 99 };
+ }
+ //out(在函数类型参数前用out修饰
+ static void ChangeValueOut(out int value)
+ {
+ value = 99;
+ }
+ static void ChangeArrayOut(out int[] arr)
+ {
+ arr = new int[] { 99, 99, 99 };
+ }
+
+
+
+
+
+
+
+
+ static void ChangeValue(int value)
+ {
+ value = 99;
+ }
+ static void ChangeArrayValue(int[] arr)
+ {
+ arr[0] = 99;//将arr2的地址传给arr,两个地址指向的地址都一样,再将地址上的值从1改为99
+ }
+
+ static void ChangeArrayValue2(int[] arr)
+ {
+ arr = new int[] { 99 };//将arr2的地址传给arr,两个地址指向的地址都一样,
+ //在新开一个arr数组,但此时arr和arr2的联系断了,
+ //arr新开了一个地址来存放99,arr2还是1
+ }
+
+
+
+
+
+
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine("尝试直接使用函数修改a的值到99:");
+ //试图使用函数修改a的值
+ int a = 1;
+ ChangeValue(a);
+ Console.WriteLine(a);//外部值不变
+ //在值类型和引用类型中有讲到,这是值类型,新开内存,拷贝值
+
+ Console.WriteLine("尝试直接使用函数修改arr2[0]的值到99:");
+ int[] arr2 = { 1, 2, 3 };//复原
+ ChangeArrayValue(arr2);
+ Console.WriteLine(arr2[0]);//内外同值99
+ //在值类型和引用类型中有讲到,这是引用类型,不新开,直接拷贝地址,arr2和函数的arr指向同一地址
+
+ Console.WriteLine("尝试直接使用函数修改arr2[0]的值到99:(但在函数中new了一个数组)");
+ arr2 = new int[] { 1, 2, 3 };//复原
+ ChangeArrayValue2(arr2);
+ Console.WriteLine(arr2[0]);//外部值不变
+ //引用类型,但是在函数内新开了内存,arr2和arr指向的不是同一地址,只修改了函数内部arr[0]的值
+
+
+ //如果在函数中new了一个数组,那么怎么保持内外部统一一个值呢
+ //ref和out就是来解决这个问题的
+ //用ref来改变值类型的值
+ Console.WriteLine("使用ref函数修改a的值到99:");
+ a = 1;//复原
+ ChangeValueRef(ref a);//需要在传入参数时也加上ref修饰符
+ Console.WriteLine(a);//内外同值99
+
+ //用ref来改变引用类型的值
+ arr2 = new int[] { 1,2,3 };//复原
+ Console.WriteLine("使用ref函数修改arr2[]的值到99:(在函数中new了一个数组)");
+ ChangeArrayRef(ref arr2);
+ Console.WriteLine(arr2[0]);//内外同值99
+
+ //用out来改变值类型的值
+ Console.WriteLine("使用out函数修改a的值到99:");
+ a = 1;//复原
+ ChangeValueOut(out a);
+ Console.WriteLine(a);
+
+ //用out来改变引用类型的值
+ Console.WriteLine("使用out函数修改arr2[]的值到99:(在函数中new了一个数组)");
+ arr2 = new int[] { 1, 2, 3};
+ ChangeArrayOut(out arr2);
+ Console.WriteLine(arr2[0]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson8_ref和out练习/Lesson8_ref和out练习.csproj b/C#基础/Lesson8_ref和out练习/Lesson8_ref和out练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson8_ref和out练习/Lesson8_ref和out练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson8_ref和out练习/Program.cs b/C#基础/Lesson8_ref和out练习/Program.cs
new file mode 100644
index 0000000..8bf3fa9
--- /dev/null
+++ b/C#基础/Lesson8_ref和out练习/Program.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Globalization;
+namespace Lesson
+{
+ class Program
+ {
+ static bool Login(string name, string password, ref string info )
+ {
+ string rightUserName = "admin";
+ string rightPassword = "admin123";
+ if (name == rightUserName && password == rightPassword)
+ {
+ return true;
+ }
+ else if (name == rightUserName && password != rightPassword )
+ {
+ info = "密码错误";
+ return false;
+ }
+ else if (name != rightUserName && password == rightPassword)
+ {
+ info = "账号错误";
+ return false;
+ }
+ else
+ {
+ info = "全错全错!";
+ return false;
+ }
+ }
+ static void Main(string[] args)
+ {
+ string inputUserName, inputPassword;
+ Console.Write("请输入用户名:");
+ inputUserName = Console.ReadLine();
+ Console.Write("请输入密码:");
+ inputPassword = Console.ReadLine();
+ string info = "";
+ bool access = Login(inputUserName,inputPassword,ref info);
+ if (access)
+ {
+ Console.WriteLine("登录成功");
+ }
+ else
+ {
+ Console.WriteLine("登录失败"+ '\n' + info);
+ }
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson9_变长参数和参数默认值/Lesson9_变长参数和参数默认值.csproj b/C#基础/Lesson9_变长参数和参数默认值/Lesson9_变长参数和参数默认值.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson9_变长参数和参数默认值/Lesson9_变长参数和参数默认值.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson9_变长参数和参数默认值/Program.cs b/C#基础/Lesson9_变长参数和参数默认值/Program.cs
new file mode 100644
index 0000000..c8a6c8c
--- /dev/null
+++ b/C#基础/Lesson9_变长参数和参数默认值/Program.cs
@@ -0,0 +1,69 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ #region 知识点一 函数语法复习
+ //1.静态关键词 可选,目前来说必须加
+ //2.返回值 没有返回值填void 可以填写任意类型变量
+ //3.函数名 帕斯卡命名法
+ //4.参数可以是任意多个,可以加ref和out作为修饰词
+ //5.如果返回值不是void 那么必须有return对应类型的内容 return可以直接打断后续代码的运行
+ #endregion
+
+ #region 知识点二 变长参数关键词
+ // 举例 函数要计算 n个整数的和
+ // 在常规写法中 static int Sum(int a, int b, ......)
+ // 需要手写很多 或 不确定个变量
+
+ // 变成参数关键字 params
+ static int Sum(params int[] arr)
+ {
+ int sum = 0;
+ for (int i = 0; i < arr.Length; i++)
+ {
+ sum += arr[i];
+ }
+ return sum;
+ }
+ //params int[]意味着可以传入n个int参数 n可以等于0 传入的参数会在arr数组中
+ //注意:
+ //1.params关键字后面必须为数组
+ //2.数组的类型可以时任意的类型
+
+ //3.函数参数可以有 别的参数 params关键字修饰的参数
+ //4.函数参数中只能最多出现一个params关键字 并且一定是在最后一组参数 前面可以有任意个其他参数
+ //示例:static void Eat(string name, int a, params int[] arr) { }
+
+ #endregion
+
+
+ #region 知识点三 参数默认值
+ //有参数默认值的参数 一般称为可选参数
+ //作用是 当调用函数时可以不传入参数,不穿就会使用默认值,作为参数的默认值
+ static void Speak(string str = "什么都没说")
+ {
+ Console.WriteLine(str);
+ }
+
+ //注意:
+ //1.支持多参数默认值 每个参数都可以有默认值
+ //2.如果要混用 可选参数 必须写在普通参数后面
+ //示例:static void Speak2(string test, string name="123",string str = "什么都没说") { }
+ //第一个参数必须传,第二个第三个可以不传
+ #endregion
+
+
+
+
+
+ static void Main(string[] args)
+ {
+ Sum();
+ Sum(1,2,3,4,5,6,7,8,9,10);//可以填写无数个参数
+
+ Speak();
+ Speak("传入参数");
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/Lesson9_变长参数和参数默认值练习/Lesson9_变长参数和参数默认值练习.csproj b/C#基础/Lesson9_变长参数和参数默认值练习/Lesson9_变长参数和参数默认值练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/Lesson9_变长参数和参数默认值练习/Lesson9_变长参数和参数默认值练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础/Lesson9_变长参数和参数默认值练习/Program.cs b/C#基础/Lesson9_变长参数和参数默认值练习/Program.cs
new file mode 100644
index 0000000..88b91e9
--- /dev/null
+++ b/C#基础/Lesson9_变长参数和参数默认值练习/Program.cs
@@ -0,0 +1,60 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ static void SumAndAvg(params int[] num)
+ {
+ if (num.Length == 0)
+ {
+ Console.WriteLine("没有东西");
+ return;
+ }
+ else
+ {
+ int sum = 0, avg;
+ for (int i = 0; i < num.Length; i++)
+ {
+ sum += num[i];
+ }
+ avg = sum / num.Length;
+ Console.WriteLine("总和为:" + sum);
+ Console.WriteLine("平均为:" + avg);
+ }
+
+ }
+
+ static void Calc(params int[] arr)
+ {
+ if(arr.Length == 0)
+ {
+ Console.WriteLine("没有东西");
+ return;
+ }
+ else
+ {
+ int sum1 = 0, sum2 = 0;
+ for (int i = 0; i < arr.Length; i++)
+ {
+ if (arr[i] % 2 == 0)
+ {
+ sum1 += arr[i];
+ }
+ else
+ {
+ sum2 += arr[i];
+ }
+ }
+ Console.WriteLine("奇数合:"+sum2);
+ Console.WriteLine("偶数合:"+sum1);
+ }
+ }
+ static void Main(string[] args)
+ {
+ SumAndAvg();
+ SumAndAvg(1,2,3,4,5,6,7,8,9,10);
+ Calc();
+ Calc(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+ }
+ }
+}
\ No newline at end of file
diff --git a/C#基础/test/Program.cs b/C#基础/test/Program.cs
new file mode 100644
index 0000000..ae5ccac
--- /dev/null
+++ b/C#基础/test/Program.cs
@@ -0,0 +1,28 @@
+using System;
+namespace Lesson
+{
+ class Program
+ {
+ #region 知识点一
+ #endregion
+
+ #region 知识点二
+ #endregion
+
+ #region 知识点三
+ #endregion
+
+ #region 知识点四
+ #endregion
+
+ #region 知识点五
+ #endregion
+
+ #region 知识点六
+ #endregion
+ static void Main(string[] args)
+ {
+
+ }
+ }
+}
diff --git a/C#基础/test/test.csproj b/C#基础/test/test.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#基础/test/test.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#基础实践教程/C#基础实践教程.sln b/C#基础实践教程/C#基础实践教程.sln
new file mode 100644
index 0000000..fa614ee
--- /dev/null
+++ b/C#基础实践教程/C#基础实践教程.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36408.4 d17.14
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C#基础实践教程", "C#基础实践教程\C#基础实践教程.csproj", "{FB791CCA-12DD-423C-9258-EAFD8DF7E269}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FB791CCA-12DD-423C-9258-EAFD8DF7E269}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FB791CCA-12DD-423C-9258-EAFD8DF7E269}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FB791CCA-12DD-423C-9258-EAFD8DF7E269}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FB791CCA-12DD-423C-9258-EAFD8DF7E269}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {18256116-5F29-4D97-BFB4-33BAE449760C}
+ EndGlobalSection
+EndGlobal
diff --git a/C#基础实践教程/C#基础实践教程/C#基础实践教程.csproj b/C#基础实践教程/C#基础实践教程/C#基础实践教程.csproj
new file mode 100644
index 0000000..64edb47
--- /dev/null
+++ b/C#基础实践教程/C#基础实践教程/C#基础实践教程.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ C_基础实践教程
+ enable
+ enable
+
+
+
diff --git a/C#基础实践教程/C#基础实践教程/Program.cs b/C#基础实践教程/C#基础实践教程/Program.cs
new file mode 100644
index 0000000..2330073
--- /dev/null
+++ b/C#基础实践教程/C#基础实践教程/Program.cs
@@ -0,0 +1,548 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Numerics;
+namespace 基础实践
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ int w = 50, h = 30;
+ ConsoleInit(w, h);
+ E_SceneType nowSceneType = E_SceneType.Begin;
+ while (true)
+ {
+ switch (nowSceneType)
+ {
+ case E_SceneType.Begin:
+ Console.Clear();
+ //开始场景逻辑
+ BeginOrQuitScene(w, h, ref nowSceneType);
+ break;
+ case E_SceneType.Game:
+ Console.Clear();
+ //游戏场景逻辑
+ GameScene(w, h, ref nowSceneType);
+ break;
+ case E_SceneType.End:
+ Console.Clear();
+ //结束场景逻辑
+ BeginOrQuitScene(w, h, ref nowSceneType);
+ break;
+ default:
+ break;
+ }
+ }
+
+ }
+ #region 控制台初始化
+ static void ConsoleInit(int w, int h)
+ {
+ //光标隐藏
+ Console.CursorVisible = false;
+ //设置窗口大小
+ Console.SetWindowSize(w, h);
+ //设置缓冲区大小
+ Console.SetBufferSize(w, h);
+ }
+ #endregion
+
+ #region 开始场景&结算场景
+ static void BeginOrQuitScene(int w, int h, ref E_SceneType nowSceneType)
+ {
+ Console.SetCursorPosition(nowSceneType == E_SceneType.Begin ? w / 2 - 2 : w / 2 - 3, 8);
+ Console.Write(nowSceneType == E_SceneType.Begin ? "飞行棋" : "游戏结束");
+ bool nowSelIndex = true;
+ bool notQuit = true;
+ while (notQuit)
+ {
+
+ Console.SetCursorPosition( w / 2 - 3, 12);
+ Console.ForegroundColor = nowSelIndex ? ConsoleColor.Red : ConsoleColor.White;
+ Console.Write(nowSceneType == E_SceneType.Begin ? "开始游戏" : "重新开始");
+ Console.SetCursorPosition(w / 2 - 3, 15);
+ Console.ForegroundColor = !nowSelIndex ? ConsoleColor.Red : ConsoleColor.White;
+ Console.Write("退出游戏");
+
+ //通过readkey可以得到一个输入的枚举类型(选中key按F12,Consolekey中有对应键值
+ switch (Console.ReadKey(true).Key)
+ {
+ case ConsoleKey.W:
+ nowSelIndex = true;
+ break;
+ case ConsoleKey.S:
+ nowSelIndex = false;
+ break;
+ case ConsoleKey.J:
+ if (nowSelIndex)
+ {
+ //进入
+ //1.改变当前场景ID
+ nowSceneType = E_SceneType.Game;
+ //2.退出当前循环
+ notQuit = false;
+ break;
+ }
+ else
+ {
+ //退出
+ Environment.Exit(0);
+ }
+ break;
+ }
+ }
+ }
+ #endregion
+
+ #region 游戏场景
+ static void GameScene(int w, int h, ref E_SceneType nowSceneType)
+ {
+ DrawWalls(w, h);
+ Map map = new Map(14, 3, 80);
+ map.Draw();
+ //grid.Draw();
+ Player player = new Player(0, E_PlayerType.Player);
+ Player computer = new Player(0, E_PlayerType.Computer);
+ bool isGameover = false;
+ DrawPlayer(player, computer, map);
+ while (true)
+ {
+ //玩家:
+ //检测输入
+ Console.ReadKey(true);
+ //扔色子
+ isGameover = RandomMove(w, h, ref player, ref computer, map);
+
+ //绘制地图
+ map.Draw();
+ //绘制玩家
+ DrawPlayer(player, computer, map);
+ //判断是否结束
+ if (isGameover)
+ {
+ nowSceneType = E_SceneType.End;
+ break;
+ }
+
+
+ //电脑:
+ //检测输入
+ Console.ReadKey(true);
+ //扔色子
+ isGameover = RandomMove(w, h, ref computer, ref player, map);
+
+ //绘制地图
+ map.Draw();
+ //绘制玩家
+ DrawPlayer(player, computer, map);
+ //判断是否结束
+ if (isGameover)
+ {
+ nowSceneType = E_SceneType.End;
+ break;
+ }
+ }
+ }
+ #endregion
+
+ #region 画红墙&提示信息
+ static void DrawWalls(int w, int h)
+ {
+ #region 墙
+ Console.ForegroundColor = ConsoleColor.Red;
+ for (int i = 0; i < w; i += 2)
+ {
+ for (int j = 0; j < h; j++)
+ {
+ if (i == 0 || j == 0 || i == w - 2 || j == h - 1 || j == h - 6 || j == h - 11)
+ {
+ Console.SetCursorPosition(i, j);
+ Console.Write('■');
+ }
+ }
+ }
+ #endregion
+ #region 提示信息
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.SetCursorPosition(2, h - 10);
+ Console.Write("□:普通格子");
+ Console.ForegroundColor = ConsoleColor.Blue;
+ Console.SetCursorPosition(2, h - 9);
+ Console.Write("Ⅱ:暂停一回合");
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.SetCursorPosition(30, h - 9);
+ Console.Write("●:炸弹(倒退5格");
+ Console.ForegroundColor = ConsoleColor.Yellow;
+ Console.SetCursorPosition(2, h - 8);
+ Console.Write("¤:混乱(随机倒退,暂停,交换玩家位置");
+ Console.ForegroundColor = ConsoleColor.Cyan;
+ Console.SetCursorPosition(2, h - 7);
+ Console.Write("★:玩家");
+ Console.ForegroundColor = ConsoleColor.Magenta;
+ Console.SetCursorPosition(16, h - 7);
+ Console.Write("▲:电脑");
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.SetCursorPosition(30, h - 7);
+ Console.Write("◎:重合");
+ #endregion
+ }
+ #endregion
+
+ #region 绘制玩家
+ static void DrawPlayer(Player player, Player computer, Map map)
+ {
+ if (player.nowIndex == computer.nowIndex)
+ {
+ Grid grid = map.grid[player.nowIndex];
+ Console.SetCursorPosition(grid.pos.x, grid.pos.y);
+ Console.ForegroundColor = ConsoleColor.Green;
+ Console.Write('◎');
+ }
+ else
+ {
+ player.Draw(map);
+ computer.Draw(map);
+ }
+
+ }
+ #endregion
+
+ #region 擦提示
+ static void ClearInfo(int h)
+ {
+ //擦之前的提示信息
+ Console.SetCursorPosition(2, h - 5);
+ Console.Write(" ");
+ Console.SetCursorPosition(2, h - 4);
+ Console.Write(" ");
+ Console.SetCursorPosition(2, h - 3);
+ Console.Write(" ");
+ Console.SetCursorPosition(2, h - 2);
+ Console.Write(" ");
+ }
+ #endregion
+
+ #region 扔骰子
+ ///
+ /// 扔骰子函数
+ ///
+ /// 窗口宽
+ /// 窗口高
+ /// 控制的对象
+ /// 地图信息
+ ///
+ static bool RandomMove(int w, int h, ref Player p, ref Player otherp, Map map)
+ {
+ //擦除提示信息
+ ClearInfo(h);
+ //根据类型 决定信息颜色
+ Console.ForegroundColor = p.type == E_PlayerType.Player ? ConsoleColor.Cyan : ConsoleColor.Magenta;
+
+ //扔骰子之前判断是否被暂停
+ if (p.isPause)
+ {
+ Console.SetCursorPosition(2, h - 5);
+ Console.Write("处于暂停,{0}需要暂停一回合",p.type == E_PlayerType.Player ? "你" : "电脑");
+ p.isPause = false;//停止暂停
+ return false;
+ }
+ Random r = new Random();
+ int randomNum = r.Next(1, 7);
+ p.nowIndex += randomNum;
+
+ //打印扔的点数
+ Console.SetCursorPosition(2, h - 5);
+ Console.Write("{0}扔出的点数为{1}", p.type == E_PlayerType.Player ? "你" : "电脑", randomNum);
+
+ if (p.nowIndex >= map.grid.Length - 1)//判断结束
+ {
+ p.nowIndex = map.grid.Length - 1;//移动大于了地图直接等于最后一格
+ Console.SetCursorPosition(2, h - 4);
+ if (p.type == E_PlayerType.Player)
+ {
+ Console.Write("恭喜你率先到达了终点");
+ }
+ else
+ {
+ Console.Write("很遗憾电脑率先到达了终点");
+ }
+ Console.SetCursorPosition(2, h - 3);
+ Console.Write("请按任意键结束");
+ return true;
+ }
+ else
+ {
+ //没到地图 就判断当前到了 什么格子
+ Grid grid = map.grid[p.nowIndex];
+ switch (grid.type)
+ {
+ case E_GridType.Normal:
+ //不处理
+ Console.SetCursorPosition(2, h - 4);
+ Console.Write("{0}无事发生", p.type == E_PlayerType.Player ? "你" : "电脑");
+ Console.SetCursorPosition(2, h - 3);
+ Console.Write("请{0}按任意键继续", p.type != E_PlayerType.Player ? "你" : "电脑");
+ break;
+ case E_GridType.Boomb:
+ //炸弹退格
+ p.nowIndex -= 5;
+ if (p.nowIndex < 0)//防止BUG小于起点
+ {
+ p.nowIndex = 0;
+ }
+ Console.SetCursorPosition(2, h - 4);
+ Console.Write("{0}踩到炸弹,退后5格", p.type == E_PlayerType.Player ? "你" : "电脑");
+ Console.SetCursorPosition(2, h - 3);
+ Console.Write("请{0}按任意键继续", p.type == E_PlayerType.Player ? "你" : "电脑");
+ break;
+ case E_GridType.Pause:
+ //暂停一回合
+ //加一个暂停标示
+ p.isPause = true;
+ break;
+ case E_GridType.Tunnel:
+ //随机
+ Console.SetCursorPosition(2, h - 4);
+ Console.Write("{0}踩到时空隧道,将触发随机效果", p.type == E_PlayerType.Player ? "你" : "电脑");
+ randomNum = r.Next(1, 91);
+ if (randomNum < 30)
+ {
+ p.nowIndex -= 5;
+ if (p.nowIndex < 0)//防止出界
+ {
+ p.nowIndex = 0;
+ }
+ Console.SetCursorPosition(2, h - 4);
+ Console.Write("{0}触发了倒退,退后5格", p.type == E_PlayerType.Player ? "你" : "电脑");
+ } else if (randomNum <= 60)
+ {
+ p.isPause = true;
+ Console.SetCursorPosition(2, h - 3);
+ Console.Write("{0}被随机到了暂停", p.type == E_PlayerType.Player ? "你" : "电脑");
+ }
+ else
+ {
+ int temp = p.nowIndex;
+ p.nowIndex = otherp.nowIndex;
+ otherp.nowIndex = temp;
+ Console.SetCursorPosition(2, h - 3);
+ Console.Write("{0}被随机到了位置互换", p.type == E_PlayerType.Player ? "你" : "电脑");
+ }
+ Console.SetCursorPosition(2, h - 2);
+ Console.Write("{0}请按键扔骰子", p.type == E_PlayerType.Player ? "你" : "电脑");
+
+ break;
+ default:
+ break;
+ }
+ }
+ return false;
+ }
+ #endregion
+
+ }
+
+ #region 场景枚举
+ enum E_SceneType
+ {
+ ///
+ /// 开始场景
+ ///
+ Begin,
+ ///
+ /// 游戏场景
+ ///
+ Game,
+ ///
+ /// 结束场景
+ ///
+ End,
+ }
+ #endregion
+
+ #region 格子枚举
+ enum E_GridType
+ {
+ ///
+ /// 普通格子
+ ///
+ Normal,
+ ///
+ /// 炸弹 会倒退
+ ///
+ Boomb,
+ ///
+ /// 暂停
+ ///
+ Pause,
+ ///
+ /// 隧道
+ ///
+ Tunnel
+ }
+ #endregion
+
+ #region 格子结构体
+ struct Grid
+ {
+ public E_GridType type;
+ public Vector2 pos;
+
+ public Grid(int x, int y, E_GridType type)
+ {
+ pos.x = x;
+ pos.y = y;
+ this.type = type;
+ }
+
+ public void Draw()
+ {
+ Console.SetCursorPosition(pos.x, pos.y);
+ switch (type)
+ {
+ case E_GridType.Normal:
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.Write("□");
+ break;
+ case E_GridType.Boomb:
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.Write("●");
+ break;
+ case E_GridType.Pause:
+ Console.ForegroundColor = ConsoleColor.Blue;
+ Console.Write("Ⅱ");
+ break;
+ case E_GridType.Tunnel:
+ Console.ForegroundColor = ConsoleColor.Yellow;
+ Console.Write("¤");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ #endregion
+
+ #region 位置信息结构体
+ struct Vector2
+ {
+ public int x;
+ public int y;
+
+ public Vector2(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+ }
+ #endregion
+
+ #region 地图结构体
+ struct Map
+ {
+ public Grid[] grid;
+ public Map(int x, int y, int num)
+ {
+ grid = new Grid[num];
+ Random r = new Random();
+ int randomNum;
+ int indexX = 0, indexY = 0;//用于位置改变的计数
+ int stepNumber = 2;
+ for (int i = 0; i < num; i++)
+ {
+ //应该初始化格子类型
+ randomNum = r.Next(1, 101);
+ //设置类型 普通格子
+ if (randomNum <= 85 || i == 0 || i == num - 1)
+ {
+ grid[i].type = E_GridType.Normal;
+ }
+ else if (randomNum > 85 && randomNum <= 90)
+ {
+ grid[i].type = E_GridType.Boomb;
+ }
+ else if (randomNum > 90 && randomNum <= 95)
+ {
+ grid[i].type = E_GridType.Pause;
+ }
+ else
+ {
+ grid[i].type = E_GridType.Tunnel;
+ }
+ //设置位置
+ grid[i].pos = new Vector2(x, y);
+ if (indexX == 10)
+ {
+ y += 1;
+ ++indexY;
+ if (indexY == 2)
+ {
+ indexX = 0;
+ indexY = 0;
+ stepNumber = -stepNumber;
+ }
+ }else
+ {
+ x += stepNumber;
+ ++indexX;
+ }
+ }
+ }
+
+ public void Draw()
+ {
+ for (int i = 0; i < grid.Length; i++)
+ {
+ grid[i].Draw();
+ }
+ }
+ }
+ #endregion
+
+ #region 玩家枚举
+ enum E_PlayerType
+ {
+ Player,
+ Computer
+ }
+ #endregion
+
+ #region 玩家结构体
+ struct Player
+ {
+ //玩家类型
+ public E_PlayerType type;
+ //当前所在地图的哪一个格子的索引
+ public int nowIndex;
+ public bool isPause;
+
+ public Player(int index, E_PlayerType type)
+ {
+ this.type = type;
+ nowIndex = index;
+ isPause = false;
+ }
+
+ public void Draw(Map mapInfo)
+ {
+ //设置位置(从传入的地图中得到格子信息
+ Grid grid = mapInfo.grid[nowIndex];
+ Console.SetCursorPosition(grid.pos.x, grid.pos.y);
+ //绘画
+ switch (type)
+ {
+ case E_PlayerType.Player:
+ Console.ForegroundColor = ConsoleColor.Cyan;
+ Console.Write("★");
+ break;
+ case E_PlayerType.Computer:
+ Console.ForegroundColor = ConsoleColor.Magenta;
+ Console.Write("▲");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ #endregion
+}
\ No newline at end of file
diff --git a/C#核心/C#核心/Program.cs b/C#核心/C#核心/Program.cs
new file mode 100644
index 0000000..3751555
--- /dev/null
+++ b/C#核心/C#核心/Program.cs
@@ -0,0 +1,2 @@
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
diff --git a/C#核心/C#核心/test.csproj b/C#核心/C#核心/test.csproj
new file mode 100644
index 0000000..5170804
--- /dev/null
+++ b/C#核心/C#核心/test.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ C_核心
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson1_类和对象/Lesson1_类和对象.csproj b/C#核心/Lesson1_类和对象/Lesson1_类和对象.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#核心/Lesson1_类和对象/Lesson1_类和对象.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson1_类和对象/Program.cs b/C#核心/Lesson1_类和对象/Program.cs
new file mode 100644
index 0000000..579c7da
--- /dev/null
+++ b/C#核心/Lesson1_类和对象/Program.cs
@@ -0,0 +1,91 @@
+namespace Lesson1_类和对象
+{
+ #region 知识回顾 面向对象概念回顾
+ //万物皆对象
+ //用程序来抽象(形容)对象
+ //用面向对象的思路来编程
+ #endregion
+
+ #region 知识点一 什么是类
+ //基本概念
+ //具有相同特征
+ //具有相同行为
+ //一类事务的抽象
+ //类是对象的模板
+ //可以通过类创建出对象来
+ //类的关键词:class
+ #endregion
+
+ #region 知识点二 类声明在哪里
+ //一般声明在namespace里声明(还有内部类不在此处
+ #endregion
+
+ #region 知识点三 类声明的语法
+ //命名:
+ //class前可以加访问修饰符,类名不建议使用中文,帕斯卡命名法
+ //注意:同一个语句块中的不同类 不能重名
+ class 类名
+ {
+ //形容一类对象的:
+ //特征-成员变量
+ //保护特征-成员属性
+
+ //构造函数和析构函数
+ //索引器
+ //运算符重载
+ //静态成员
+ }
+ #endregion
+
+ #region 知识点四 类声明实例
+ class Human//用来形容人类的
+ {
+
+ }
+
+ class Machine//用来形容机器的
+ {
+
+ }
+ #endregion
+
+
+
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+
+ #region 知识点五 什么是(类)对象
+ //基本概念
+ // 类的声明 和 类对象(变量)声明是两个概念
+ // 类的声明 类似 枚举 和 结构体的声明 类的声明相当于声明了一个自定义变量类型
+ // 而对象 是类创建出来的
+ // 相当于声明一个指定类的变量
+ // 类创建对象的过程一般称为实例化对象
+ // 类对象 都是引用类型的(还有数组和string
+ #endregion
+
+ #region 知识点六 实例化对象基本语法
+ //类名 变量名;
+ //类名 变量名 = null; null代表空
+ //类名 变量名 = new 类名(); 会调用类的构造函数
+ #endregion
+
+ #region 知识点七 实例化对象
+ Human h;//在栈上开辟一个空间 来 存储 堆空间 的 内存地址 ,但是现在没放所以栈空间内容是空的
+ Human h2 = null;//和上面一样
+ Human h3 = new Human();//在栈上开辟一个空间来存储堆空间的内存地址,但堆的内容是空的
+ Human h4 = new Human();//假如构造函数中有内容,此刻要注意!
+ //虽然和上面一样都是Human()实例化出来的对象,但其中的内容并不共享
+
+
+ //总结:
+ //类对象和类的声明是两个东西
+ //类的声明是声明对象的模板 用来(抽象)形容实例的
+ //类对象的声明是 用来表示实际对象个体的
+ #endregion
+ }
+ }
+}
diff --git a/C#核心/Lesson1_类和对象练习/Lesson1_类和对象练习.csproj b/C#核心/Lesson1_类和对象练习/Lesson1_类和对象练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#核心/Lesson1_类和对象练习/Lesson1_类和对象练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson1_类和对象练习/Program.cs b/C#核心/Lesson1_类和对象练习/Program.cs
new file mode 100644
index 0000000..be04bc3
--- /dev/null
+++ b/C#核心/Lesson1_类和对象练习/Program.cs
@@ -0,0 +1,10 @@
+namespace Lesson1_类和对象练习
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ }
+ }
+}
diff --git a/C#核心/Lesson2_成员变量和访问修饰符/Lesson2_封装-成员变量和访问修饰符.csproj b/C#核心/Lesson2_成员变量和访问修饰符/Lesson2_封装-成员变量和访问修饰符.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#核心/Lesson2_成员变量和访问修饰符/Lesson2_封装-成员变量和访问修饰符.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson2_成员变量和访问修饰符/Program.cs b/C#核心/Lesson2_成员变量和访问修饰符/Program.cs
new file mode 100644
index 0000000..65f089e
--- /dev/null
+++ b/C#核心/Lesson2_成员变量和访问修饰符/Program.cs
@@ -0,0 +1,118 @@
+namespace Lesson2_成员变量和访问修饰符
+{
+ #region 知识回顾
+ // 类和对象
+ // 声明类
+ //class 类名
+ //{
+ // //形容一类对象的:
+ // //特征-成员变量//////////////////////////////////本课重点
+ // //保护特征-成员属性
+
+ // //构造函数和析构函数
+ // //索引器
+ // //运算符重载
+ // //静态成员
+ //}
+ // 实例化对象
+ // 类名 变量名;
+ // 类名 变量名 = null;
+ // 类名 变量名 = new 类名();
+ #endregion
+
+ #region 知识点一 成员变量
+ //基本规则
+ //1.声明在类语句块中
+ //2.用来描述对象的特征
+ //3.可以是任意变量类型
+ //4.数量不做限制
+ //5.是否赋值根据需求决定
+
+ //性别
+ enum E_Sex
+ {
+ male = 0,
+ female = 1
+ }
+ //位置
+ struct Position
+ {
+ public int x;
+ public int y;
+ public Position(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+ }
+ //宠物
+ class Pet
+ {
+
+ }
+ //人
+ class Human
+ {
+ //特征-成员变量
+ //姓名
+ public string name = "HK";//可以初始化(但意义不大),结构体中不可以
+ //年龄
+ public int age;
+ //性别
+ public E_Sex sex;
+ //伴侣
+ public Human girlfriend;
+ //类中这么写是可以的 因为类会默认为null
+ //结构体不能这么写 因为结构体必须初始化
+ //注意!
+ //在类中声明一个类名相同的成员变量时
+ //不能对其进行实例化(可以为null,但是不能直接初始化new一个,会造成死循环)
+
+ public Human[] friend;
+
+ public Position pos;
+
+ public Pet pet;
+ }
+ #endregion
+
+ #region 知识点二 访问修饰符
+ // public 公共的 自己(内部)和别人(外部)都能访问和使用
+ // private 私有的 自己(内部)才可以访问和使用 不写 默认为此private
+ // protected 保护的 自己(内部)和子类才能访问和使用
+ // 目前决定类内部的成员 的 访问权限
+ #endregion
+
+
+
+ #region 知识点四
+ #endregion
+
+ #region 知识点五
+ #endregion
+
+ #region 知识点六
+ #endregion
+
+ #region 知识点七
+ #endregion
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ #region 知识点三
+ #endregion
+
+ Human h = new Human();
+ //值类型来说 数字类型的默认值都是0 bool类型都是false
+ //引用类型的 null
+ //看默认值的方法
+ Console.WriteLine(default(int));
+ Console.WriteLine(default(Human));//打印null看不到
+
+ h.age = 10;
+ Console.WriteLine(h.age);
+ }
+ }
+}
diff --git a/C#核心/Lesson2_成员变量和访问修饰符练习/Lesson2_封装-成员变量和访问修饰符练习.csproj b/C#核心/Lesson2_成员变量和访问修饰符练习/Lesson2_封装-成员变量和访问修饰符练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#核心/Lesson2_成员变量和访问修饰符练习/Lesson2_封装-成员变量和访问修饰符练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson2_成员变量和访问修饰符练习/Program.cs b/C#核心/Lesson2_成员变量和访问修饰符练习/Program.cs
new file mode 100644
index 0000000..93b41b7
--- /dev/null
+++ b/C#核心/Lesson2_成员变量和访问修饰符练习/Program.cs
@@ -0,0 +1,68 @@
+namespace Lesson2_成员变量和访问修饰符练习
+{
+ class Person
+ {
+ public int age,height;
+ public string name,address;
+ }
+ class Student
+ {
+ public string name;
+ public int number, age;
+ public Student deskmate;
+ void Study()
+ {
+ Console.WriteLine();
+ }
+ }
+ class Cla
+ {
+ public string Major;
+ public int TeacherCapacity,StudentCapacity;
+
+ }
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ //Console.WriteLine("Hello, World!");
+ //Person p = new Person();
+ //Person p2 = new Person();
+ //p.age = 10;
+ //p2.age = 20;
+ ////不同对象的存储空间不同,所以值不会相同
+ //Console.WriteLine(p.age);
+ //Console.WriteLine(p2.age);
+
+ Person p = new Person();
+ p.age = 10;
+ Person p2 = p;
+ p2.age = 20;
+ //p2指向了p的内存地址,共享一块地址,所以p2改了,p也会改为20
+ Console.WriteLine(p.age);
+ Console.WriteLine(p2.age);
+
+ //Student s = new Student();
+ //s.age = 10;
+ //int age = s.age;
+ //age = 20;
+ ////因为age是值类型,是一个新的空间,所以s.age不受影响
+ //Console.WriteLine(s.age);
+ //Console.WriteLine(age);
+
+ Student s = new Student();
+ s.deskmate = new Student();
+ s.deskmate.age = 10;
+ Student s2 = s.deskmate;
+ s2.age = 20;
+ //s.deskmate虽然new了空间在后面被指向了s2的地址
+ //所以s.deskmate的地址是和s2共享的 s.deskmate就是s2
+ //s2.age变了s.deskmate.age也会变
+ Console.WriteLine(s.deskmate.age);
+ Console.WriteLine(s2.age);
+
+ Cla c = new Cla();
+
+ }
+ }
+}
diff --git a/C#核心/Lesson3_封装-成员方法/Lesson3_封装-成员方法.csproj b/C#核心/Lesson3_封装-成员方法/Lesson3_封装-成员方法.csproj
new file mode 100644
index 0000000..0ab1770
--- /dev/null
+++ b/C#核心/Lesson3_封装-成员方法/Lesson3_封装-成员方法.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson3_封装_成员方法
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson3_封装-成员方法/Program.cs b/C#核心/Lesson3_封装-成员方法/Program.cs
new file mode 100644
index 0000000..695623b
--- /dev/null
+++ b/C#核心/Lesson3_封装-成员方法/Program.cs
@@ -0,0 +1,77 @@
+namespace Lesson3_封装_成员方法
+{
+ #region 知识点一 成员方法声明
+ //基本概念
+ //1.声明在类语句块中
+ //2.是用来描述对象的行为的
+ //3.规则和函数声明规则相同
+ //4.收到访问修饰符规则影响
+ //5.返回值参数不做限制
+ //6.方法数量不做限制
+
+ //注意:
+ //1.成员方法不要加static关键字
+ //2.成员方法 必须实例化出对象 再通过对象来使用 详单与该对象执行了某个行为
+ //3.成员方法 收到访问修饰符限制
+
+ class Person
+ {
+ public string name;
+ public int age;
+
+ public void Speak(string str)
+ {
+ Console.WriteLine("{0}说{1}",name,str);
+ }
+
+ public bool IsAdult()
+ {
+ return age >= 18;
+ }
+ public Person[] friend;
+ ///
+ /// 加朋友的方法
+ ///
+ /// p是传入的新朋友
+ public void AddFriend(Person p)
+ {
+ if (friend == null)
+ {
+ friend = new Person[] { p };
+ }
+ else
+ {
+ Person[] temp = new Person[friend.Length];
+ for (int i = 0; i < friend.Length; i++)
+ {
+ temp[i] = friend[i];
+ }
+ temp[temp.Length -1] = p;
+ friend = temp;
+ }
+ }
+ }
+ #endregion
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ #region 知识点二 成员方法的使用
+ Person p = new Person();
+ p.name = "HK";
+ p.age = 18;
+ p.Speak("hello");
+ Console.WriteLine(p.IsAdult() ? "成年了" : "没成年");
+ Person p2 = new Person();
+ p2.name = "KH";
+ p2.age = 18;
+ p.AddFriend(p2);
+ for (int i = 0; i < p.friend.Length; i++)
+ {
+ Console.WriteLine("{0}是{1}的朋友",p.friend[i].name,p.name);
+ }
+ #endregion
+ }
+ }
+}
diff --git a/C#核心/Lesson3_封装-成员方法练习/Lesson3_封装-成员方法练习.csproj b/C#核心/Lesson3_封装-成员方法练习/Lesson3_封装-成员方法练习.csproj
new file mode 100644
index 0000000..0270ca9
--- /dev/null
+++ b/C#核心/Lesson3_封装-成员方法练习/Lesson3_封装-成员方法练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson3_封装_成员方法练习
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson3_封装-成员方法练习/Program.cs b/C#核心/Lesson3_封装-成员方法练习/Program.cs
new file mode 100644
index 0000000..5195b70
--- /dev/null
+++ b/C#核心/Lesson3_封装-成员方法练习/Program.cs
@@ -0,0 +1,66 @@
+namespace Lesson3_封装_成员方法练习
+{
+ enum E_Occupation
+ {
+ Student = 0,
+ Teacher = 1,
+ }
+ class Person
+ {
+ public string name;
+ public string age;
+
+
+ public void Speak(string str)
+ {
+ Console.WriteLine("{0}说了{1}", name, str);
+ }
+ public void Walk()
+ {
+ Console.WriteLine("{0}走了路", name);
+ }
+ public void Eat(Food food)
+ {
+ Console.WriteLine("{0}吃了{1},共计{2}卡路里", name, food.name, food.Calorie);
+ }
+ }
+ class Student
+ {
+ public string name;
+ public void Study()
+ {
+ Console.WriteLine("{0}学了习", name);
+ }
+ public void Eat(Food food)
+ {
+ Console.WriteLine("{0}吃了{1},共计{2}卡路里", name, food.name, food.Calorie);
+ }
+ }
+ class Food
+ {
+ public string name;
+ public int Calorie;
+
+ }
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Person p = new Person();
+ p.name = "Test";
+ p.Speak("hello");
+ p.Walk();
+ //p.Eat();
+ Student s = new Student();
+ s.name = "Test2";
+ s.Study();
+ //s.Eat();
+
+ Food bread = new Food();
+ bread.name = "Bread";
+ bread.Calorie = 200;
+ s.Eat(bread);
+ p.Eat(bread);
+ }
+ }
+}
diff --git a/C#核心/Lesson4_封装-构造函数和析构函数/Lesson4_封装-构造函数和析构函数.csproj b/C#核心/Lesson4_封装-构造函数和析构函数/Lesson4_封装-构造函数和析构函数.csproj
new file mode 100644
index 0000000..02a322d
--- /dev/null
+++ b/C#核心/Lesson4_封装-构造函数和析构函数/Lesson4_封装-构造函数和析构函数.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson4_封装_构造函数和析构函数
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson4_封装-构造函数和析构函数/Program.cs b/C#核心/Lesson4_封装-构造函数和析构函数/Program.cs
new file mode 100644
index 0000000..9271b6a
--- /dev/null
+++ b/C#核心/Lesson4_封装-构造函数和析构函数/Program.cs
@@ -0,0 +1,165 @@
+namespace Lesson4
+{
+ internal class Program
+ {
+ #region 知识点一 构造函数
+ //基本概念
+ //在实例化对象时 会调用的用于初始化的函数
+ //如果不屑 默认存在一个无参的构造函数
+
+ //构造函数的写法
+ //1.没有返回值
+ //2.函数名和类名必须相同
+ //3.没有特殊需求是 一般都是public
+ //class Person
+ //{
+ // public string name;
+ // public int age;
+
+ // //类允许自己声明无参构造函数(结构体不允许
+ // public Person()
+ // {
+ // name = "HK";
+ // age = 18;
+ // }
+ // public Person(string name, int age)//当使用Person p2 = new Person("HK",19);时调用的就是这里的函数
+ // {
+ // this.name = name;//将 外部 传进来的name和age 传给 类 下面的name和age
+ // this.age = age;
+ // }
+ // //此时有参构造函数已经写了,如果我没写上面的无参构造函数,原本不写就默认有的无参构造函数会无效
+ //}
+
+ //4.构造函数可以被重载
+ //5.this代表当前调用该函数的对象自己
+
+ //注意:
+ //如果不自己实现无参构造函数而实现了有参构造函数
+ //会失去默认的无参构造函数
+ #endregion
+
+ #region 知识点二 构造函数特殊写法
+ //可以通过this 宠用构造函数代码
+ //访问修饰符 构造函数名(参数列表):this(参数1,参数2.....)
+ //class Person
+ //{
+ // public string name;
+ // public int age;
+
+ // public Person()
+ // {
+ // name = "HK";
+ // age = 18;
+ // }
+ // public Person(string name)
+ // {
+ // this.name = name;
+ // }
+ // public Person(int age)
+ // {
+ // this.age = age;
+ // }
+ // public Person(string name, int age): this(name) //写了this()
+ // //就先调用无参构造函数(类似默认赋值)
+ // //this()中如果是空的
+ // //直接执行本有参构造函数
+ // //this()中如果写了name,就会调用只有一个name的有参构造函数
+ // //然后再执行本有参构造函数
+ // {
+ // Console.WriteLine("Person两个参数构造函数调用");
+ // }
+ //}
+ #endregion
+
+ #region 知识点三 析构函数(了解
+ //基本概念
+ //当引用类型的堆内存被回收时,会调用该函数
+ //对于需要手动管理内存的语言(比如C++),需要在析构函数中做一些垃圾回收处理
+ //但是C#中存在自动垃圾回收机制GC
+ //所以我们几乎不会怎么使用析构函数。除非你想在某一个对象被垃圾回收时,做一些特殊处理
+ //注意:
+ //在Unity开发中析构函数几乎不会使用,所以该知识点只做了解即可
+
+ //基本语法
+ //~类名()
+ //{
+ //}
+
+ class Person
+ {
+ public string name;
+ public int age;
+
+ public Person()
+ {
+ name = "HK";
+ age = 18;
+ }
+ public Person(string name)
+ {
+ this.name = name;
+ }
+ public Person(int age)
+ {
+ this.age = age;
+ }
+ public Person(string name, int age) : this(name)
+ {
+ Console.WriteLine("Person两个参数构造函数调用");
+ }
+ //引用类型堆内存被回收时才会执行
+ ~Person() { }//析构函数
+ //当垃圾 真正被回收时 才会被调用
+ }
+ #endregion
+
+ #region 知识点四 垃圾回收机制
+ //垃圾回收,英文简写GC(Garbage Collector)
+ //垃圾回收的过程是在遍历堆(Heep)上动态分配的所有对象
+ //通过识别他们是否被引用来确定哪些对象时垃圾,哪些对象仍要被使用
+ //所谓的垃圾就是没有被任何变量,对象引用的内容
+ //垃圾就需要被回收释放
+
+ //垃圾回收有很多种算法,比如
+ //引用计数(Reference Counting)
+ //标记清除(Mark Sweep)
+ //标记整理(Mark Compact)
+ //复制集合(Copy Collection)
+
+ //注意:
+ //GC只负责堆(Heap)内存垃圾的回收
+ //引用类型都是存在堆(Heap)中的,所以他的分配和释放都通过垃圾回收机制来管理
+
+ //栈(Stack)上的内存是由系统自动管理的
+ //值类型是在栈(Stack)中分配内存的,他们有自己的声明周期,不用对他们进行管理,会自动分配和释放
+
+ //C#中的内存回收机制的大概原理
+ //0代内存 1代内存 2代内存
+ //代的概念:
+ //代是垃圾回收机制使用的一种算法(分代算法)
+ //新分配的对象都会被配置在第0代内存中
+ //每次分配都可能会进行垃圾回收以及内存释放(0代内存满时)
+
+ //在依次内存回收过程开始时,垃圾回收器会认为堆中全是垃圾,会进行以下两步
+ //1.标记对象 从根(静态字段、方法参数)开始检查引用对象,标记后为可达对象,未标记为不可达对象
+ // 不可达对象就被认为是垃圾
+ //2.搬迁对象压缩堆(挂起执行托管代码线程)释放未标记的对象 搬迁可达对象 修改引用地址
+
+ //大对象总被人为是第二代内存
+ //不会对大对象进行搬迁压缩 85000字节(83kb)以上的对象为大对象
+
+ #endregion
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ Person p = new Person();
+ Console.WriteLine(p.age);//自己默认的无参构造函数,数值为18
+ Person p2 = new Person("HK",19);
+ Console.WriteLine(p2.age);//上面实例化的19
+
+ GC.Collect();//手动回收垃圾
+ //一般都是在加载或场景切换时才使用
+ }
+ }
+}
diff --git a/C#核心/Lesson4_封装-构造函数和析构函数练习/Lesson4_封装-构造函数和析构函数练习.csproj b/C#核心/Lesson4_封装-构造函数和析构函数练习/Lesson4_封装-构造函数和析构函数练习.csproj
new file mode 100644
index 0000000..e23887a
--- /dev/null
+++ b/C#核心/Lesson4_封装-构造函数和析构函数练习/Lesson4_封装-构造函数和析构函数练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson4_封装_构造函数和析构函数练习
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson4_封装-构造函数和析构函数练习/Program.cs b/C#核心/Lesson4_封装-构造函数和析构函数练习/Program.cs
new file mode 100644
index 0000000..a85f8bd
--- /dev/null
+++ b/C#核心/Lesson4_封装-构造函数和析构函数练习/Program.cs
@@ -0,0 +1,101 @@
+using System.Runtime.InteropServices;
+
+namespace Lesson4_封装_构造函数和析构函数练习
+{
+ class Person
+ {
+ public string name;
+ public int age;
+ public Person(string name, int age)
+ {
+ this.name = name;
+ this.age = age;
+ }
+ }
+ class Clas
+ {
+ public string name, major;
+ Person[] student;
+ public Clas(string name, string major, Person[] student)
+ {
+ this.name = name;
+ this.major = major;
+ this.student = student;
+ }
+ public void PrintInfo(Person[] student)
+ {
+ Console.WriteLine("{0}班级中学生信息",name);
+ for (int i = 0; i < student.Length; i++)
+ {
+ Console.WriteLine("student的姓名:" + student[i].name + "student的年龄:" + student[i].age);
+ }
+ }
+ }
+ class Ticket
+ {
+ public uint distant;
+
+ public Ticket()
+ {
+ distant = 0;
+ }
+ public Ticket(uint distant)
+ {
+ this.distant = distant;
+ }
+ public void GetDistant()
+ {
+ Console.WriteLine(distant);
+ }
+ public void GetPrice()
+ {
+ double price = 0d;
+ if (distant <= 100)
+ {
+ price = distant;
+ }
+ else if (distant <= 200)
+ {
+ price = Convert.ToDouble(distant * 0.95);
+ }
+ else if (distant <= 300)
+ {
+ price = Convert.ToDouble(distant * 0.9);
+ }
+ else
+ {
+ price = Convert.ToDouble(distant * 0.8);
+ }
+ Console.WriteLine(price);
+
+ }
+ }
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Person p1 = new Person("张三", 3);
+ Person p2 = new Person("李四", 4);
+
+ Console.WriteLine("P1姓名:" + p1.name + "P1年龄" + p1.age);
+ Console.WriteLine("P2姓名:" + p2.name + "P2年龄" + p2.age);
+ Person[] student = { p1, p2 };
+ Console.WriteLine("把P1和P2放到Person的student之后");
+ Console.WriteLine("student[0]的姓名:"+ student[0].name+ "student[0]的年龄:" + student[0].age);
+ Console.WriteLine("student[1]的姓名:" + student[1].name + "student[1]的年龄:" + student[1].age);
+
+
+ Clas c1 = new Clas("三年一班","计算机",student);
+ c1.PrintInfo(student);
+
+ Ticket t = new Ticket();
+ Console.Write("默认情况下的距离:");
+ t.GetDistant();
+ Console.Write("赋值初始化后的距离:");
+ Ticket t2 = new Ticket(300);
+ t2.GetDistant();
+ Console.Write("赋值初始化后的价格计算:");
+ t2.GetPrice();
+ }
+ }
+}
diff --git a/C#核心/Lesson5_封装-成员属性/Lesson5_封装-成员属性.csproj b/C#核心/Lesson5_封装-成员属性/Lesson5_封装-成员属性.csproj
new file mode 100644
index 0000000..f8af281
--- /dev/null
+++ b/C#核心/Lesson5_封装-成员属性/Lesson5_封装-成员属性.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson5_封装_成员属性
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson5_封装-成员属性/Program.cs b/C#核心/Lesson5_封装-成员属性/Program.cs
new file mode 100644
index 0000000..2e88320
--- /dev/null
+++ b/C#核心/Lesson5_封装-成员属性/Program.cs
@@ -0,0 +1,165 @@
+namespace Lesson5
+{
+ #region 知识回顾
+ //class Person
+ //{
+ // //特征——成员变量
+ // private int age;
+ // private string name;
+ // //金钱
+ // private int money;
+ // //行为——成员方法
+ // public void Speak()
+ // {
+
+ // }
+ // //初始化调用——构造函数
+ // public Person(int age) { }
+ // public Person(int age, string name) { }
+ // //释放时调用——析构函数
+ // ~Person() { }
+ //}
+ #endregion
+
+ #region 知识点一 成员属性的基本概念
+ //基本概念
+ //1.用于保护乘员变量
+ //2.称为成员属性获取和赋值添加逻辑处理
+ //3.解决3p的局限性
+ // public_内外访问
+ // private_内外访问
+ // protected_内部和子类访问
+ // 属性可以让成员变量在外部
+ // 只能获取 不能修改 或者 只能修改 不能获取
+ #endregion
+
+ #region 知识点二 成员属性的基本语法
+ // 访问修饰符 属性类型 属性名
+ // {
+ // get{}
+ // set{}
+ // }
+ class Person
+ {
+ private string name;
+ private int age;
+ private int money;
+ private bool sex;
+
+ public Person()
+ {
+ sex = true;
+ }
+
+ //属性一般用帕斯卡命名法
+ public string Name
+ {
+ get//必须要有一个返回值
+ {
+ //可以在返回之前添加一些逻辑规则
+ //意味着 这个属性可以获取的内容
+ return name;
+ }
+ set
+ {
+ //可以在设置之前添加一些逻辑
+ // value关键字 用于 表示外部传入的值
+ name = value;
+ }
+ }
+ //public int Money
+ //{
+ // get
+ // {
+ // return Value + 5;//通过加减来对数据进行加密
+ // }
+ // set
+ // {
+ // money = value - 5;
+ // }
+ //}
+ public void TrueGetMoney()
+ {
+ Console.WriteLine(money);
+ }
+ #endregion
+
+ #region 知识点四 成员属性中 get和set钱可以加访问修饰符
+ // 注意
+ // 1.默认不加 会使用属性声明时的访问权限
+ // 2.记得访问修饰符要地狱属性的访问权限
+ // 3.不能让get和set的访问权限都低于属性的权限
+ public int Money
+ {
+ get
+ {
+ return 0;
+ }
+ set
+ {
+ if (value < 0)
+ {
+ Console.WriteLine("钱不能少于0,被设为0");
+ value = 0;
+ }
+ money = value;
+ }
+ }
+ #endregion
+
+
+ #region 知识点五 get和set可以只有一个
+ public bool Sex
+ {
+ get
+ {
+ return sex;//可以得不能改
+ }
+ }
+ #endregion
+
+ #region 知识点六 自动属性
+ //作用:外部能得不能改的特征
+ //如果类中有一个特征时希望外部能得到不能改 又没什么特殊处理
+ //那么可以直接使用自动属性
+
+ public float Height//没有height成员变量,但是用Height属性来代替了成员变量(
+ //自动生成一个地址来存放成员变量,我们也不知道成员变量名是什么,反正用这个属性包裹起来了
+ //作用是
+ //可以在get和set前设置访问修饰符,直接修改 设置和访问成员变量 的权限不用再去声明一个变量在写多几行代码
+ //但是get和set中没法对数据进行处理(加密等)
+ {
+ get;
+ set;
+ }
+ #endregion
+ }
+
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ #region 知识点三 成员属性的使用
+ Person p = new Person();
+ p.Name = "Test";
+ Console.WriteLine(p.Name);
+ p.Money = 100;
+ Console.WriteLine(p.Money);
+ p.TrueGetMoney();
+ p.Money = -100;
+ p.TrueGetMoney();
+ Console.WriteLine(p.Sex);//只能得,不能p.Sex = False来改
+ #endregion
+
+ }
+ }
+ //总结
+ //1.成员属性概念:一般是用来保护成员变量的
+ //2.成员属性的使用和变量一样 外部用对象点出
+ //3.get中需要return内容;set中用value表示传入的内容
+ //4.get和set语句块中可以加逻辑处理
+ //5.get和set可以加访问修饰符,但是要按照一定的规则进行添加
+ //6.get和set可以只有一个
+ //7.自动属性是属性语句块中只有get和set,一般用于 外部能得不饿能改这种情况
+}
diff --git a/C#核心/Lesson5_封装-成员属性练习/Lesson5_封装-成员属性练习.csproj b/C#核心/Lesson5_封装-成员属性练习/Lesson5_封装-成员属性练习.csproj
new file mode 100644
index 0000000..b36f5d0
--- /dev/null
+++ b/C#核心/Lesson5_封装-成员属性练习/Lesson5_封装-成员属性练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson5_封装_成员属性练习
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson5_封装-成员属性练习/Program.cs b/C#核心/Lesson5_封装-成员属性练习/Program.cs
new file mode 100644
index 0000000..0c34474
--- /dev/null
+++ b/C#核心/Lesson5_封装-成员属性练习/Program.cs
@@ -0,0 +1,129 @@
+using System.Runtime.Intrinsics.Arm;
+
+namespace Lesson5_封装_成员属性练习
+{
+ class Student
+ {
+ private int age,csharpscore,unityscore;
+ private string sex;
+ public Student() { }
+ public Student(string name,int age,string sex,int csharp,int unity)
+ {
+ this.Name = name;
+ this.Sex = sex;
+ this.Age = age;
+ this.CsharpScore = csharp;
+ this.UnityScore = unity;
+ }
+ public string Name
+ {
+ get;
+ set;
+ }
+ public string Sex
+ {
+ get { return sex; }
+ set
+ {
+ if (value == "男" || value == "女")
+ {
+ sex = value;
+ }
+ else
+ {
+ sex = "不男不女";
+ }
+ }
+ }
+ public int Age
+ {
+ get
+ {
+ return age;
+ }
+ set
+ {
+ if (value < 0)
+ {
+ age = 0;
+ Console.WriteLine("年龄不在范围内");
+ }else if (value > 150)
+ {
+ age = 150;
+ Console.WriteLine("年龄不在范围内");
+ }else
+ {
+ age = value;
+ }
+ }
+ }
+ public int CsharpScore
+ {
+ get
+ {
+ return csharpscore;
+ }
+ set
+ {
+ if (value < 0 || value > 100)
+ {
+ csharpscore = 0;
+ Console.WriteLine("分数不在范围内");
+ }
+ else
+ {
+ csharpscore = value;
+ }
+ }
+ }
+ public int UnityScore
+ {
+ get
+ {
+ return unityscore;
+ }
+ set
+ {
+ if (value < 0 || value > 100)
+ {
+ unityscore = 0;
+ Console.WriteLine("分数不在范围内");
+ }
+ else
+ {
+ unityscore = value;
+ }
+ }
+ }
+ public void Greet()
+ {
+ Console.WriteLine("我叫{0}, 今年{1}岁,是{2}生", Name, Age, Sex);
+ }
+ public void ShowTotalScore()
+ {
+ int total = CsharpScore + UnityScore;
+ float avg = total / 2f;
+ Console.WriteLine("你的总分是:"+total+"平均分是:"+avg);
+ }
+ }
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Test1:");
+ Student s1 = new Student();
+ s1.Name = "Test1";
+ s1.Sex = "男";
+ s1.Age = 123;
+ s1.CsharpScore = 60;
+ s1.UnityScore = 60;
+ s1.Greet();
+ s1.ShowTotalScore();
+ Console.WriteLine("Test2:");
+ Student s2 = new Student("test2",666,"超人",60,666);
+ s2.Greet();
+ s2.ShowTotalScore();
+
+ }
+ }
+}
diff --git a/C#核心/Lesson6_封装-索引器/Lesson6_封装-索引器.csproj b/C#核心/Lesson6_封装-索引器/Lesson6_封装-索引器.csproj
new file mode 100644
index 0000000..5458d76
--- /dev/null
+++ b/C#核心/Lesson6_封装-索引器/Lesson6_封装-索引器.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson6_封装_索引器
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson6_封装-索引器/Program.cs b/C#核心/Lesson6_封装-索引器/Program.cs
new file mode 100644
index 0000000..42c80da
--- /dev/null
+++ b/C#核心/Lesson6_封装-索引器/Program.cs
@@ -0,0 +1,130 @@
+namespace Lesson6
+{
+ internal class Program
+ {
+ #region 知识回顾
+ class 类名
+ {
+ #region 特征——成员变量
+ #endregion
+
+ #region 行为——成员方法
+ #endregion
+
+ #region 初始化调用——构造方法
+ #endregion
+
+ #region 释放时调用——析构方法
+ #endregion
+
+ #region 保护成员变量——成员属性
+ #endregion
+ }
+ #endregion
+
+ #region 知识点一 索引器的基本概念
+ //基本概念
+ //让对象可以像数组一样通过索引器访问其中元素,使程序看起来更只管,更容易编写
+ //(不用数组了)
+ #endregion
+
+ #region 知识点二 索引器基本语法
+ //访问修饰符 返回值 this[参数类型 参数名,参数类型 参数名......]
+ //{
+ // 内部的写法可规则和索引器相同
+ // get{}
+ // set{}
+ //}
+ class Person
+ {
+ private string name;
+ private int age;
+ private Person[] friends;
+ private int[,] array;
+
+ #region 知识点五 索引器可以重载
+ //重载的概念是————函数名相同 但 参数类型、数量、顺序不同
+ #endregion
+ public int this[int i, int j]
+ {
+ get
+ {
+ return array[i, j];
+ }
+ set
+ {
+ array[i, j] = value;
+ }
+ }
+ public string this[string str]
+ {
+ get
+ {
+ switch (str)
+ {
+ case "name":
+ return this.name;
+ case "age":
+ return this.age.ToString();
+ default:
+ return "";
+ }
+ }
+ set
+ {
+ this[str] = value;
+ }
+ }
+ public Person this[int index]
+ {
+ get
+ {
+ #region 知识点四 索引器中可以写逻辑
+ #endregion
+ if (friends == null)
+ {
+ return null;
+ }
+ else if (friends.Length - 1 < index)
+ {
+ return null;
+ }
+ else
+ {
+ return friends[index];
+ }
+ }
+ set
+ {
+ if (friends == null)
+ {
+ friends = new Person[] { value };
+ }else if(index > friends.Length -1)
+ {
+ friends = new Person[] { value };
+ }
+ }
+ }
+ }
+ #endregion
+
+
+
+
+ #region 知识点六
+ #endregion
+
+ #region 知识点七
+ #endregion
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ #region 知识点三
+ Person p = new Person();
+ p[0] = new Person();
+ Console.WriteLine(p[0]);
+ p[0, 0] = 10;
+ #endregion
+ }
+ }
+}
diff --git a/C#核心/Lesson6_封装-索引器练习/Lesson6_封装-索引器练习.csproj b/C#核心/Lesson6_封装-索引器练习/Lesson6_封装-索引器练习.csproj
new file mode 100644
index 0000000..d322c9d
--- /dev/null
+++ b/C#核心/Lesson6_封装-索引器练习/Lesson6_封装-索引器练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson6_封装_索引器练习
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson6_封装-索引器练习/Program.cs b/C#核心/Lesson6_封装-索引器练习/Program.cs
new file mode 100644
index 0000000..87898af
--- /dev/null
+++ b/C#核心/Lesson6_封装-索引器练习/Program.cs
@@ -0,0 +1,145 @@
+using System.Runtime.InteropServices;
+
+namespace Lesson6_封装_索引器练习
+{
+ class IntArray
+ {
+ private int[] array;
+ private int used, capacity;
+ public IntArray()
+ {
+ capacity = 5;
+ array = new int[capacity];
+ used = 0;
+ }
+ //增
+ public void Add(int value)
+ {
+ if (used < capacity)
+ {
+ array[used] = value;
+ used++;
+ }
+ else
+ {
+ capacity += 1;
+ int[] newArray = new int[capacity];
+ for (int i = 0; i < array.Length; i++)
+ {
+ newArray[i] = array[i];
+ }
+ array = newArray;
+
+ array[used] = value;
+ used++;
+ }
+ }
+ //删
+ public void DelValue(int target)
+ {
+ for (int i = 0; i < used; i++)
+ {
+ if(target == array[i])
+ {
+ DelIndex(i);
+ return;
+ }
+ }
+ Console.WriteLine("没找到");
+ }
+ public void DelIndex(int target)
+ {
+ if (target > array.Length - 1)
+ {
+ Console.WriteLine("当前数组只有{0}长,溢出",used);
+ }
+ else
+ {
+ for (int i = target; i < used-1; i++)
+ {
+ array[i] = array[i + 1];
+ }
+ for (int i = used - 1; i < used; i++)
+ {
+ array[i] = 0;
+ }
+ }
+ --used;
+
+ }
+ public int this[int index]
+ {
+ get
+ {
+ if (index >= capacity)
+ {
+ Console.WriteLine("已溢出,当前index:"+index+'\n'+"当前已用值:"+(used)+"当前容量:"+(capacity));
+ return 0;
+ }
+ else
+ {
+ return array[index];
+ }
+
+ }
+ set
+ {
+ Console.WriteLine(index);
+ array[index] = value;
+ }
+ }
+ }
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ IntArray a = new IntArray();
+ a.Add(1);
+ a.Add(2);
+ a.Add(3);
+ a.Add(4);
+ a.Add(5);
+ a.Add(6);
+ a.Add(7);
+ a.Add(8);
+ a.Add(9);
+ a.Add(10);
+ Console.WriteLine("dfdf" + a[0]);
+ Console.WriteLine("dfdf" + a[1]);
+ Console.WriteLine("dfdf" + a[2]);
+ Console.WriteLine("dfdf" + a[3]);
+ Console.WriteLine("dfdf" + a[4]);
+ Console.WriteLine("dfdf" + a[5]);
+ Console.WriteLine("dfdf" + a[6]);
+ Console.WriteLine("dfdf" + a[7]);
+ Console.WriteLine("dfdf" + a[8]);
+ Console.WriteLine("dfdf" + a[9]);
+ Console.WriteLine("越界测试" + a[10]);
+ Console.WriteLine();
+ a.DelIndex(3);
+ Console.WriteLine("dfdf" + a[0]);
+ Console.WriteLine("dfdf" + a[1]);
+ Console.WriteLine("dfdf" + a[2]);
+ Console.WriteLine("dfdf" + a[3]);
+ Console.WriteLine("dfdf" + a[4]);
+ Console.WriteLine("dfdf" + a[5]);
+ Console.WriteLine("dfdf" + a[6]);
+ Console.WriteLine("dfdf" + a[7]);
+ Console.WriteLine("dfdf" + a[8]);
+ Console.WriteLine("dfdf" + a[9]);
+ Console.WriteLine();
+ a.DelValue(7);
+ Console.WriteLine("dfdf" + a[0]);
+ Console.WriteLine("dfdf" + a[1]);
+ Console.WriteLine("dfdf" + a[2]);
+ Console.WriteLine("dfdf" + a[3]);
+ Console.WriteLine("dfdf" + a[4]);
+ Console.WriteLine("dfdf" + a[5]);
+ Console.WriteLine("dfdf" + a[6]);
+ Console.WriteLine("dfdf" + a[7]);
+ Console.WriteLine("dfdf" + a[8]);
+ Console.WriteLine("dfdf" + a[9]);
+ }
+ }
+}
diff --git a/C#核心/Lesson7_静态成员/Lesson7_封装-静态成员.csproj b/C#核心/Lesson7_静态成员/Lesson7_封装-静态成员.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#核心/Lesson7_静态成员/Lesson7_封装-静态成员.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson7_静态成员/Program.cs b/C#核心/Lesson7_静态成员/Program.cs
new file mode 100644
index 0000000..fffa712
--- /dev/null
+++ b/C#核心/Lesson7_静态成员/Program.cs
@@ -0,0 +1,96 @@
+namespace Lesson7
+{
+ #region 知识点一 静态成员基本概念
+ //静态关键字 static
+ //用static 修饰的 成员变量、方法、属性等
+ //称为静态成员
+
+ //静态成员的特点是:直接用类名点出使用
+ #endregion
+
+ #region 知识点二 早已出现的静态成员
+ //console的writeline
+ #endregion
+
+ #region 知识点三 自定义静态成员
+ class test
+ {
+ //静态成员变量
+ public static float PI = 3.1415926f;
+
+ public int testInt = 100;
+
+ public static float CalcCircle(float r)
+ {
+ #region 知识点六 静态函数中不能使用非静态成员
+ //成员变量只能将对象实例化出来后 才能点出来使用 不能无中生有
+ //不能直接使用非静态成员,否则会报错
+ //Console.WriteLine(testInt);
+ ////如果要使用,必须先实例化(分配出一个内存)
+ //test t = new test();
+ ////然后再调用
+ //Console.WriteLine(t.testInt);
+ #endregion
+ return r * r * PI;
+ }
+
+ public void TestFun()
+ {
+ #region 知识点七 非静态函数可以使用静态成员
+ //也是因为生命周期造成的(已经分配内存了
+ Console.WriteLine(test.PI);
+ #endregion
+ Console.WriteLine("test123");
+ }
+ }
+ #endregion
+
+ #region 知识点五 为什么可以直接点出来使用
+ //记住!
+ //程序中是不能无中生有的
+ //我们使用的对象、变量、函数都是要在内存中分配空间的
+ //之所以要实例化对象,目的就是分配内存空间,在程序中产生一个抽象的对象
+
+ //静态成员的特点
+ //程序开始运行时 就会分配内存空间,所以我们就能直接使用
+ //静态成员和程序同生共死
+ //只要使用了他,知道程序结束时内存才会被释放
+ //所以一个静态成员就会有自己唯一的一个“内存小房间”
+ //这让静态成员就有了唯一性
+ //在仍和地方使用都是用的小房间里的内容,改变了它也是改变小房间里的内容
+ #endregion
+
+ #region 知识点八 静态成员对于我们的作用
+ //静态变量:
+ //1.常用唯一的变量 比如 重力加速度
+ //2.方便别人获取的对象声明 比如 PI
+ //静态方法:
+ //常用的唯一的方法声明 比如 相同规则的数学计算相关函数
+ #endregion
+
+ #region 知识点九 常量和静态常量
+ //const(常量)可以理解为特殊的static(静态)
+ //相同点
+ //他们都可以通过类名点出使用
+ //不同点
+ //1.const必须初始化,不能修改 static没有这个规则
+ //2.const只能修饰变量,static可以修饰类、方法等
+ //3.const一定是写在访问修饰符后面的,static没有这个要求
+ #endregion
+
+ internal class Program
+ {
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ #region 知识点四 静态成员的使用
+ Console.WriteLine(test.PI);
+ Console.WriteLine(test.CalcCircle(2));
+
+ test t = new test();
+ Console.WriteLine(t.testInt);
+ #endregion
+ }
+ }
+}
diff --git a/C#核心/Lesson7_静态成员练习/Lesson7_封装-静态成员练习.csproj b/C#核心/Lesson7_静态成员练习/Lesson7_封装-静态成员练习.csproj
new file mode 100644
index 0000000..2150e37
--- /dev/null
+++ b/C#核心/Lesson7_静态成员练习/Lesson7_封装-静态成员练习.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson7_静态成员练习/Program.cs b/C#核心/Lesson7_静态成员练习/Program.cs
new file mode 100644
index 0000000..1bdce8d
--- /dev/null
+++ b/C#核心/Lesson7_静态成员练习/Program.cs
@@ -0,0 +1,38 @@
+namespace Lesson7_静态成员练习
+{
+ //一个类对象,在整个应用程序的生命周期中,有且只有一个该对象的存在
+ //不能在外部实例化,直接通过该类名就能得到位的的对象
+ class test
+ {
+ private static test t = new test();//2.new一个对象,就可以用test.t来的到这个类对象
+ //这样就有且只有一个该对象的存在
+ //4.private来让外部不能设置null
+ public int testInt = 10;
+ public static test T//5.写一个成员属性来定义设置和取值的方法
+ //这样就可以只让读,不让写
+ {
+ get
+ {
+ return t; //让t来包裹test.T,那么test.T.testInt和t.testInt就是相同的
+ }
+ set
+ {
+ Console.WriteLine("你可不能随便动");
+ }
+ }
+ public test()//1.默认无参构造函数定义为private
+ //这样不能在外部实例化 即在类外部test t = new test();
+ //3.但是虽然不能new一个对象,可以在外部设置为null
+ {
+ }
+ }
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ Console.WriteLine(test.T.testInt);
+ }
+ }
+}
+
diff --git a/C#核心/Lesson8_封装-静态类和静态构造函数/Lesson8_封装-静态类和静态构造函数.csproj b/C#核心/Lesson8_封装-静态类和静态构造函数/Lesson8_封装-静态类和静态构造函数.csproj
new file mode 100644
index 0000000..9579b57
--- /dev/null
+++ b/C#核心/Lesson8_封装-静态类和静态构造函数/Lesson8_封装-静态类和静态构造函数.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson8_封装_静态类和静态构造函数
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson8_封装-静态类和静态构造函数/Program.cs b/C#核心/Lesson8_封装-静态类和静态构造函数/Program.cs
new file mode 100644
index 0000000..5e70c45
--- /dev/null
+++ b/C#核心/Lesson8_封装-静态类和静态构造函数/Program.cs
@@ -0,0 +1,125 @@
+namespace Lesson8
+{
+ #region 知识回顾
+ class 类名
+ {
+ #region 特征——成员变量
+ #endregion
+
+ #region 行为——成员方法
+ #endregion
+
+ #region 初始化调用——构造方法
+ #endregion
+
+ #region 释放时调用——析构方法
+ #endregion
+
+ #region 保护成员变量——成员属性
+ #endregion
+
+ #region 索引器
+ #endregion
+
+ #region 静态成员
+ #endregion
+ }
+ #endregion
+
+
+
+ #region 知识点一 静态类
+ //概念
+ //用static修饰的类
+
+ //特点
+ //只能包含静态成员
+ //不能被实例化
+
+ //作用
+ //1.将常用的静态成员写在静态类中 方便使用
+ //2.静态类不能被实例化,更能体现工具类的 唯一性
+ //比如 consle就是一个静态类
+
+ static class Tools
+ {
+ public static int testIndex = 0;//静态成员变量
+
+ public static void TestFun() { }
+ public static int TestIndex
+ {
+ get { return testIndex; }
+ set { testIndex = value; }
+ }
+ }
+ #endregion
+
+
+
+ #region 知识点二 静态构造函数
+ //概念
+ //在构造函数加上 static 修饰
+
+ //特点
+ //1.静态类和普通类都可以有
+ //2.不能使用访问修饰符
+ //3.不能有参数
+ //4.只会自动调用依次
+
+ //作用
+ //在静态构造函数中初始化
+
+ //1.静态类中的静态构造函数
+ static class StaticClass
+ {
+ public static int testInt = 100;
+ public static int testInt2 = 200;
+ public static int testInt3;
+
+ static StaticClass()
+ {
+ Console.WriteLine("静态构造函数");
+ testInt3 = 300;
+ }
+ }
+ //2.普通类中的静态构造函数
+ class NormalClass
+ {
+ public int testInt;
+ public int testInt2 = 200;
+ public static int testInt3;
+ static NormalClass()
+ {
+ testInt3 = 300;
+ Console.WriteLine("静态构造函数");
+ }
+ public NormalClass()
+ {
+ testInt = 100;
+ testInt3 = 300;
+ Console.WriteLine("构造函数");
+ }
+ }
+ #endregion
+
+
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+
+ Console.WriteLine(StaticClass.testInt);
+
+ Console.WriteLine(StaticClass.testInt2);
+
+ Console.WriteLine(StaticClass.testInt3);
+
+
+ Console.WriteLine(NormalClass.testInt3);
+ NormalClass n1 = new NormalClass();
+ Console.WriteLine(n1.testInt);
+ Console.WriteLine(n1.testInt2);
+ }
+ }
+}
diff --git a/C#核心/Lesson8_封装-静态类和静态构造函数练习/Lesson8_封装-静态类和静态构造函数练习.csproj b/C#核心/Lesson8_封装-静态类和静态构造函数练习/Lesson8_封装-静态类和静态构造函数练习.csproj
new file mode 100644
index 0000000..17dfcee
--- /dev/null
+++ b/C#核心/Lesson8_封装-静态类和静态构造函数练习/Lesson8_封装-静态类和静态构造函数练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson8_封装_静态类和静态构造函数练习
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson8_封装-静态类和静态构造函数练习/Program.cs b/C#核心/Lesson8_封装-静态类和静态构造函数练习/Program.cs
new file mode 100644
index 0000000..c1cdb68
--- /dev/null
+++ b/C#核心/Lesson8_封装-静态类和静态构造函数练习/Program.cs
@@ -0,0 +1,48 @@
+namespace Lesson8_封装_静态类和静态构造函数练习
+{
+ static class Calc
+ {
+ private static float PI = 3.1415926f;
+ public static float CalcCirclePerimeter(int r)
+ {
+ return PI * r * 2;
+ }
+ public static float CalcCircleArea(int r)
+ {
+ return PI * r * r;
+ }
+ public static int CalcRectanglePerimeter(int h,int w)
+ {
+ return (h + w) * 2;
+ }
+ public static int CalcRectangleArea(int h, int w)
+ {
+ return h * w;
+ }
+ public static int Absolute(int num)
+ {
+ if (num < 0)
+ {
+ return -num;
+ }
+ else
+ {
+ return num;
+ }
+ }
+
+ }
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ Console.WriteLine(Calc.CalcRectanglePerimeter(5,10));
+ Console.WriteLine(Calc.CalcRectangleArea(5, 10));
+ Console.WriteLine(Calc.CalcCirclePerimeter(3));
+ Console.WriteLine(Calc.CalcCircleArea(3));
+ Console.WriteLine(Calc.Absolute(123));
+ Console.WriteLine(Calc.Absolute(-321));
+ }
+ }
+}
diff --git a/C#核心/Lesson9_封装-拓展方法/Lesson9_封装-拓展方法.csproj b/C#核心/Lesson9_封装-拓展方法/Lesson9_封装-拓展方法.csproj
new file mode 100644
index 0000000..c495880
--- /dev/null
+++ b/C#核心/Lesson9_封装-拓展方法/Lesson9_封装-拓展方法.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson9_封装_拓展方法
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson9_封装-拓展方法/Program.cs b/C#核心/Lesson9_封装-拓展方法/Program.cs
new file mode 100644
index 0000000..ecc8ec9
--- /dev/null
+++ b/C#核心/Lesson9_封装-拓展方法/Program.cs
@@ -0,0 +1,117 @@
+namespace Lesson9
+{
+ #region 知识回顾
+ class 类名
+ {
+ #region 特征——成员变量
+ #endregion
+
+ #region 行为——成员方法
+ #endregion
+
+ #region 初始化调用——构造方法
+ #endregion
+
+ #region 释放时调用——析构方法
+ #endregion
+
+ #region 保护成员变量——成员属性
+ #endregion
+
+ #region 索引器
+ #endregion
+
+ #region 静态成员
+ #endregion
+ }
+ #region 静态类和静态构造函数
+ #endregion
+ #endregion
+
+ #region 知识点一 拓展方法基本概念
+ //概念
+ //为现有的非静态 变量类型 添加 新方法
+ //作用
+ //1.提高程序的拓展性
+ //2.不需要在对象中重新写方法
+ //3.不需要继承来添加方法(继承没学
+ //4.为别人封装的类型写额外的方法
+ //特点
+ //1.一定是写在静态类中的
+ //2.一定是静态函数
+ //3.第一个参数为拓展目标
+ //4.第一个参数用this修饰
+ #endregion
+
+ #region 知识点二 基本语法
+ //访问修饰符 static 返回值 函数名(this 拓展类名 参数名,参数类型 参数名,参数类型 参数名,.....)
+ #endregion
+
+ #region 知识点三 实例
+ static class Tools
+ {
+ //为int拓展一个成员方法
+ //成员方法是需要实例化对象后才能使用的
+ //value 代表 使用该方法的 实例化对象
+ public static void SpeakValue(this int value)
+ {
+ //拓展方法的逻辑
+ Console.WriteLine("拓展int方法" + value);
+ }
+
+ public static void SpeakString(this string value,string value2,string value3)
+ {
+ Console.WriteLine("拓展的string方法");
+ Console.WriteLine("调用方法的对象" + value);
+ Console.WriteLine("传的参数" + value2+value3);
+ }
+ public static void Fun3(this Test t)//为test t拓展的Fun3
+ {
+ Console.WriteLine("tools为test扩展的方法3");
+ }
+ public static void Fun1(this Test t2)//同名了,在test类的实例化对象中无法调用这里的函数
+ {
+ Console.WriteLine("tools为test扩展的方法4");
+ }
+ }
+ #endregion
+
+ #region 知识点五 为自定义的类型拓展方法
+ class Test
+ {
+ public int i = 10;
+ public void Fun1()
+ {
+ Console.WriteLine("test的fun1");
+ }
+ public void Fun2()
+ {
+ Console.WriteLine("test的fun2");
+ }
+ }
+ #endregion
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ #region 知识点四 使用
+
+ int i = 10;//i是实例化对象
+ i.SpeakValue();//虽然需要一个参数,
+ //但这只是一个规则,可以不写这个value
+ //执行后是:拓展int方法10
+
+
+ string str = "000";
+ str.SpeakString("value2","value3");//鼠标停留在函数名上可以看到需要传哪些参数
+
+
+ Test t = new Test();
+ t.Fun3();//可以调用其他类中为其扩展的方法
+
+ Test t2 = new Test();
+ t2.Fun1();//当两个类中有同名的方法,仅会调用本类中的方法
+ #endregion
+ }
+ }
+}
diff --git a/C#核心/Lesson9_封装-拓展方法练习/Lesson9_封装-拓展方法练习.csproj b/C#核心/Lesson9_封装-拓展方法练习/Lesson9_封装-拓展方法练习.csproj
new file mode 100644
index 0000000..cd42d82
--- /dev/null
+++ b/C#核心/Lesson9_封装-拓展方法练习/Lesson9_封装-拓展方法练习.csproj
@@ -0,0 +1,11 @@
+
+
+
+ Exe
+ net8.0
+ Lesson9_封装_拓展方法练习
+ enable
+ enable
+
+
+
diff --git a/C#核心/Lesson9_封装-拓展方法练习/Program.cs b/C#核心/Lesson9_封装-拓展方法练习/Program.cs
new file mode 100644
index 0000000..bafb70f
--- /dev/null
+++ b/C#核心/Lesson9_封装-拓展方法练习/Program.cs
@@ -0,0 +1,67 @@
+namespace Lesson9_封装_拓展方法练习
+{
+ static class Tools
+ {
+ public static int IntSqrt(this int i)
+ {
+ return i*i;
+ }
+ public static void Suicide(this player p)
+ {
+ Console.WriteLine("{0}自杀了",p.name);
+ }
+ }
+ class player
+ {
+ public string name;
+ public int hp, atk, def;
+ public player()
+ {
+ name = "null";
+ hp = 0;
+ atk = 0;
+ def = 0;
+ }
+ public player(string name,int hp,int atk,int def)
+ {
+ this.name =name;
+ this.hp = hp;
+ this.atk = atk;
+ this.def = def;
+ }
+ public void Attack()
+ {
+ Console.WriteLine("{0}攻击了,攻击值{1}",name,atk);
+ }
+ public void Defense()
+ {
+ Console.WriteLine("{0}防御了,防御值{1}",name,def);
+ }
+ public void Move()
+ {
+ Console.WriteLine("{0}移动了",name);
+ }
+ public void GetHurt()
+ {
+ Console.WriteLine("{0}受伤了,剩余{1}hp",name,hp);
+ }
+ }
+ internal class Program
+ {
+ static void Main(string[] args)
+ {
+ player p = new player();
+ p.Attack();
+ p.Defense();
+ p.Move();
+ p.GetHurt();
+ p.Suicide();
+ player p2 = new player("HK",100,100,100);
+ p2.Attack();
+ p2.Defense();
+ p2.Move();
+ p2.GetHurt();
+ p2.Suicide();
+ }
+ }
+}