diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/Linux\347\273\203\344\271\240.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/Linux\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..fc7f48ec93fe1aeac2ad8db3dbccec6ef25af636 --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/Linux\347\273\203\344\271\240.md" @@ -0,0 +1,100 @@ +## Linux练习 +### 任务1 +尝试使用以下几种方式分别登录服务器,说明它们分别的注意事项,并说明它们之间的区别 +ssh客户端 +tabby应用 +xShell +putty + +用户界面:SSH客户端和PuTTY较为简单,Tabby提供了现代化的界面,xShell提供了用户友好的图形界面。 + +平台支持:SSH客户端和PuTTY支持多平台,Tabby支持Windows、macOS和Linux,xShell主要针对Windows。 + +功能:SSH客户端功能强大但界面简单,PuTTY轻量级,Tabby和xShell提供了更多现代功能,如多标签和插件系统。 + +安全性:所有工具都支持SSH加密连接,但使用密钥对认证可以提供额外的安全性。 + +易用性:对于不熟悉命令行的用户,Tabby和xShell提供了更好的易用性。 + +### 任务2 +更新软件源,命令:apt update,并了解这一步的实际用处和意义: + +apt update命令是apt工具中的一个常用命令,用于更新本地软件包索引。 +它确保了你的系统软件包列表是最新的,这对于系统的维护、升级和安全性至关重要。 + +### 任务3 +更新软件和补丁,命令:apt upgrade -y,并了解这一步的实际用处意义 + +apt upgrade -y 是一个在基于Debian的Linux发行版(如Ubuntu)中使用的命令,用于升级所有已安装的软件包到最新版本。这个命令结合了 apt update 和 apt upgrade 的功能,并且自动回答“yes”以确认所有升级。 + +### 任务4 +``` +查看当前目录下的文件和文件夹 +命令:ls + +查看当前路径 +命令:pwd + +创建一个新的文件夹 +命令:mkdir [文件夹名] 例如:mkdir new_folder + +删除一个文件夹(注意:只能删除空文件夹) +命令:rmdir [文件夹名] 例如:rmdir new_folder + +移动或重命名文件/文件夹 +命令:mv [原路径] [新路径] 例如:mv old_name.txt new_name.txt + +复制文件 +命令:cp [源文件] [目标路径] 例如:cp file1.txt /path/to/destination/ + +删除文件 +命令:rm [文件名] 例如:rm file.txt + +查看文件内容 +命令:cat [文件名] 例如:cat file.txt + +分页查看文件内容 +命令:less [文件名] 例如:less file.txt + +查找文件 +命令:find / -name [文件名] 例如:find / -name filename.txt + +查看文件权限 +命令:ls -l [文件或目录名] 例如:ls -l file.txt + +改变文件权限 +命令:chmod [权限] [文件或目录名] 例如:chmod 755 file.txt(设置为可读可写可执行) + +改变文件所有者 +命令:chown [新所有者] [文件或目录名] 例如:chown new_owner file.txt + +查看当前登录用户 +命令:whoami + +查看系统运行时间和平均负载 +命令:uptime + +查看磁盘使用情况 +命令:df -h(以易读的格式显示) + +查看当前路径下的隐藏文件 +命令:ls -a + +创建一个空文件 +命令:touch [文件名] 例如:touch new_file.txt + +查看当前系统的内核版本 +命令:uname -r + +查看网络连接状态 +命令:ifconfig 或 ip addr(ifconfig 命令在某些新版本的Linux中已被ip命令取代) + +安装一个软件包 +命令:sudo apt-get install [软件包名] 例如:sudo apt-get install vim + +卸载一个软件包 +命令:sudo apt-get remove [软件包名] 例如:sudo apt-get remove vim + +更新软件包列表 +命令:sudo apt-get update +``` \ No newline at end of file diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/MVC\347\273\203\344\271\240.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/MVC\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..89126c74160fba879ceb3804fec4b7864b8186e4 --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/MVC\347\273\203\344\271\240.md" @@ -0,0 +1,104 @@ +### 1、创建一个控制台项目,没有任何选项,体会项目名称和什么有关系 +dotnet new console -n MyConsoleApp +### 2、创建一个控制项目,项目名称Blog +dotnet new console -n Blog +### 3、创建一个控制台项目,输出到Blog目录 +mkdir Blog +cd Blog +dotnet new console +### 4、创建一个MVC项目,指定项目名称 +dotnet new mvc -n MyMvcProject +### 5、创建一个MVC项目,指定输出目录 +mkdir MyMvcProject +cd MyMvcProject +dotnet new mvc -o . +### 6、创建一个带解决方案,其下有一个MVC项目,3个类库项目的“综合项目” +dotnet new sln -n ComprehensiveSolution +cd ComprehensiveSolution +dotnet new mvc -n MvcProject +dotnet sln add MvcProject +dotnet new classlib -n ClassLibrary1 +dotnet new classlib -n ClassLibrary2 +dotnet new classlib -n ClassLibrary3 +dotnet sln add ClassLibrary1 ClassLibrary2 ClassLibrary3 +### 7、创建一个项目,在默认控制器(Home)下,新增一个Action方法,名为Ok,同时为其创建对应视图以显示这个视图 +``` +dotnet new mvc -n MyMvcApp +cd MyMvcApp +public IActionResult Ok() +{ + return View(); +} +

Ok

+

This is the Ok view.

+``` +### 8、创建一个项目,创建一个新的控制器,名为Blogs,新的控制器拥有一个名为Index的Action,该方法返回一个视图,视图显示“神级预判” +``` +dotnet new mvc -n MyMvcApp +cd MyMvcApp +public class BlogsController : Controller +{ + public IActionResult Index() + { + return View(); + } +} +在Views/Blogs目录下创建Index.cshtml视图文件,并添加以下内容: +

Index

+

神级预判

+``` +### 9、给第8题的新控制,添加一个新的Action,名为Music,不接受任何参数,并返回对应的视图,视图显示“顶级打野” +``` +public IActionResult Music() +{ + return View(); +} +在Views/Blogs目录下创建Music.cshtml视图文件,并添加以下内容: +

Music

+

顶级打野

+``` +### 10、给第8题的新控制器,新增一个Action,名为List,不接受任何参数,并返回对应视图,视图显示一个经典CRUD界面 +``` +在BlogsController.cs中添加: +public IActionResult List() +{ + return View(); +} +在Views/Blogs目录下创建List.cshtml视图文件,并添加以下内容: +

List

+

This is a classic CRUD interface.

+``` +### 11、新增一个控制器,名为Products,该控制器具有一个名为Edit的Action,这个Action接受一个int类型的参数id,显示这个id +``` +创建ProductsController.cs: +public class ProductsController : Controller +{ + public IActionResult Edit(int id) + { + ViewBag.Id = id; + return View(); + } +} +在Views/Products目录下创建Edit.cshtml视图文件,并添加以下内容: +

Edit

+

ID: @ViewBag.Id

+``` +### 12、在11题的新控制器中,新增一个名为Create的Action,该Action接受一个类型为Students(有姓名、年龄、体长属性)的参数,并展示该参数的姓名属性 +``` +首先定义Students类: +public class Students +{ + public string Name { get; set; } + public int Age { get; set; } + public double Height { get; set; } +} +在ProductsController.cs中添加: +public IActionResult Create(Students student) +{ + ViewBag.Name = student.Name; + return View(); +} +在Views/Products目录下创建Create.cshtml视图文件,并添加以下内容: +

Create

+

Name: @ViewBag.Name

+``` \ No newline at end of file diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/\345\237\272\347\241\200\350\203\275\345\212\233.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/\345\237\272\347\241\200\350\203\275\345\212\233.md" new file mode 100644 index 0000000000000000000000000000000000000000..b4e250003260dc5c586bf2bc1c09ff3a7ec50e72 --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\220\216\344\275\234\344\270\232/\345\237\272\347\241\200\350\203\275\345\212\233.md" @@ -0,0 +1,63 @@ +### 生成一个随机整数,范围[0,100],注意是否包含 +``` +public IActionResult Create(){ + int num = new Random().Next(0,101); + return Content(num.ToString()); + } + +``` +### 生成一个随机整数,范围(0,100],注意是否包含 +``` +public IActionResult Create(){ + int num = new Random().Next(0,101); + return Content(num.ToString()); + } + +``` +### 生成10个随机整数,范围[5,80],注意是否包含 +``` +public IActionResult Create(){ + int num = new Random().Next(5,81); + return Content(num.ToString()); + } +``` +### 定义一个字符串,字符串中有100个中文字符,需要从中随机取1个字符串 +``` +public IActionResult Create(){ + string text = "天地玄黄宇宙洪荒日月盈昃辰宿列张寒来暑往秋收冬藏闰余成岁律吕调阳云腾致雨露结为霜金生丽水玉出昆冈剑号巨阙珠称夜光果珍李柰菜重芥姜海咸河淡鳞潜羽翔龙师火帝鸟官人皇始制文字乃服衣裳推位让国有虞陶唐吊民伐罪周发殷汤坐朝问道垂拱平章爱育黎首臣伏戎羌遐迩一体率宾不宁载戢干戈载櫜弓矢民协厥中临深履薄同律度量垂宪章乘风破浪举重若轻" + int num = new Random().Next(0,text.Length); + return Content([num].ToString()); + } +``` +### 定义一个字符串,字符串中有100个中文字符,需要从中随机取5-50个字符,组成新的字符 +``` +public IActionResult Create(){ + string text = "天地玄黄宇宙洪荒日月盈昃辰宿列张寒来暑往秋收冬藏闰余成岁律吕调阳云腾致雨露结为霜金生丽水玉出昆冈剑号巨阙珠称夜光果珍李柰菜重芥姜海咸河淡鳞潜羽翔龙师火帝鸟官人皇始制文字乃服衣裳推位让国有虞陶唐吊民伐罪周发殷汤坐朝问道垂拱平章爱育黎首臣伏戎羌遐迩一体率宾不宁载戢干戈载櫜弓矢民协厥中临深履薄同律度量垂宪章乘风破浪举重若轻" + int num1 = new Random().Next(4,50); + string str = ""; + for (int i = 0; i < num1; i++) + { + int num2 = new Random().Next(0,text.Length); + str+=text[num2]; + } + return Content(str); + } +``` +### 定义2个字符串,第一个字符串中放百家姓,第二个字符串中放中文字符,要求从第一个字符串随机取得一个姓,再从第二个字符串中随机获得1到2个字符组成新字符串,和第一个字符串取得的姓组成一个姓名 +``` +public IActionResult Create(){ + string surname_name=""; + string surname="赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫经房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄麴家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘景詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲邰从丛鄂索咸籍赖卓蔺屠蒙池乔阴欎胥能苍双闻莘党翟谭贡劳逄姬" + int ranSueName = new Random().Next(0,surname_name.Length); + surname_name+=bname[surname]; + + string name = "天地玄黄宇宙洪荒日月盈昃辰宿列张寒来暑往秋收冬藏闰余成岁律吕调阳云腾致雨露结为霜金生丽水玉出昆冈剑号巨阙珠称夜光果珍李柰菜重芥姜海咸河淡鳞潜羽翔龙师火帝鸟官人皇始制文字乃服衣裳推位让国有虞陶唐吊民伐罪周发殷汤坐朝问道垂拱平章爱育黎首臣伏戎羌遐迩一体率宾不宁载戢干戈载櫜弓矢民协厥中临深履薄同律度量垂宪章乘风破浪举重若轻" + int ran = new Random().Next(1,3); + for(int i = 0;i` + +专业项练习-视图及其模板引擎 +### 渲染(展示)简单数据类型到视图 +![20241201210711](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241201210711.png) +### 渲染(展示)对象数据到视图 +![20241201211501](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241201211501.png) +### 渲染(展示)集合数据到视图 +![20241201212018](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241201212018.png) +### 渲染(展示)包含集合数据的对象数据到视图 +![20241201213230](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241201213230.png) +### 尝试构建如下图所示的经典CRUD列表 +![20241201215648](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241201215648.png) + + diff --git "a/\346\262\210\350\202\262\346\236\227/20241114-\346\226\207\344\273\266\347\273\223\346\236\204\344\273\245\345\217\212\346\263\250\346\204\217\351\241\271.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241114-\347\275\221\347\253\231\346\220\255\345\273\272.md" similarity index 88% rename from "\346\262\210\350\202\262\346\236\227/20241114-\346\226\207\344\273\266\347\273\223\346\236\204\344\273\245\345\217\212\346\263\250\346\204\217\351\241\271.md" rename to "\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241114-\347\275\221\347\253\231\346\220\255\345\273\272.md" index 99627c5de98c022701287ba07078da202c1f65d6..9c4860446e9d6cd8d50644af9cd165afee631777 100644 --- "a/\346\262\210\350\202\262\346\236\227/20241114-\346\226\207\344\273\266\347\273\223\346\236\204\344\273\245\345\217\212\346\263\250\346\204\217\351\241\271.md" +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241114-\347\275\221\347\253\231\346\220\255\345\273\272.md" @@ -15,7 +15,6 @@ * views -> 视图(需要跟控制器一一对应 | 控制器类名(去掉Controllr) =》 文件夹名称 / 控制器类名的方法名 =》 控制器类名内的方法名.cshtml文件) * controllers -> 控制器(命名需要加上Controller) 简单的基本语法: - ![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241114185907.png) * obj 和 bin -> 缓存软件 * Models -> 存放应用程序的数据模型(一般是数据库) * appsettings.json -> 存储应用程序的配置信息 @@ -28,4 +27,4 @@ 关闭:`ctrl + c` # 今日练习 -![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241114190632.png) +![20241117220429](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241117220429.png) diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241119-\346\216\247\345\210\266\345\231\250.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241119-\346\216\247\345\210\266\345\231\250.md" new file mode 100644 index 0000000000000000000000000000000000000000..2276b3f1e88e2ec4a887886662090ae7cb107b4d --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241119-\346\216\247\345\210\266\345\231\250.md" @@ -0,0 +1,12 @@ +### 控制器 +名字:控制器名+Controller.cs 文件内的基本组成: +``` +using Microsoft.AspNetCore.Mvc +namespace MVC项目名.Controlers; +public class 类名 : Controller +{ + public 返回值 方法名(参数){ + return 值; + } +} +``` \ No newline at end of file diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241121-\346\216\247\345\210\266\345\231\250\345\217\202\346\225\260.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241121-\346\216\247\345\210\266\345\231\250\345\217\202\346\225\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..bde8728b8aa00fba9fb6657f4d6358b2ecc32bf5 --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241121-\346\216\247\345\210\266\345\231\250\345\217\202\346\225\260.md" @@ -0,0 +1,5 @@ +### 方式1--地址传参 +url/值 接收一般为id,可以在路由更改。 + +### 方式2--[FromBody]传参 +定义一个类接收 类名CreateDto 定义属性 访问前提: 类前面加请求方式[HttpPost] 参数前面加[FromBody] \ No newline at end of file diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241122-\350\277\224\345\233\236\345\200\274.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241122-\350\277\224\345\233\236\345\200\274.md" new file mode 100644 index 0000000000000000000000000000000000000000..c5212fe4c48110bbe438488d6c6db5a03ea26839 --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241122-\350\277\224\345\233\236\345\200\274.md" @@ -0,0 +1,6 @@ +### 控制器返回值 +一般数据类型 +IActionResult类型(接口) +ActionResult类型(接口加一般数据类型) +特定于格式的操作结果 +Poco(普通旧CLR对象) \ No newline at end of file diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241126-\346\255\243\345\217\215\345\220\221\344\273\243\347\220\206.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241126-\346\255\243\345\217\215\345\220\221\344\273\243\347\220\206.md" new file mode 100644 index 0000000000000000000000000000000000000000..95b84d8ed827ab95ccc2a4f7d45ac7b62181066f --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241126-\346\255\243\345\217\215\345\220\221\344\273\243\347\220\206.md" @@ -0,0 +1,26 @@ +## 正向代理 +定义:正向代理服务器位于客户端和目标服务器之间,客户端通过代理服务器访问目标服务器。 + +作用: + +隐藏客户端的真实IP地址,保护客户端隐私。 + +缓存请求结果,提高访问速度。 + +过滤请求,进行内容审查。 + +作为防火墙,保护内部网络不受外部攻击。 + +## 反向代理 +定义:反向代理服务器位于目标服务器和客户端之间,客户端直接与代理服务器通信,而代理服务器再将请求转发给目标服务器。 + +作用: +隐藏后端服务器的真实IP地址,保护服务器安全。 + +负载均衡,将请求分发到多个后端服务器。 + +SSL加密,提高数据传输安全性。 + +压缩和缓存静态内容,提高访问速度。 + +提供额外的安全层,如Web应用防火墙(WAF)。 diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241205-\350\241\250\345\215\225\347\254\224\350\256\260\345\212\240\347\273\203\344\271\240.md" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241205-\350\241\250\345\215\225\347\254\224\350\256\260\345\212\240\347\273\203\344\271\240.md" new file mode 100644 index 0000000000000000000000000000000000000000..7f0af307e7d1f6418fec93cf7170251c841e1a6b --- /dev/null +++ "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/20241205-\350\241\250\345\215\225\347\254\224\350\256\260\345\212\240\347\273\203\344\271\240.md" @@ -0,0 +1,317 @@ +## 表单 +基本表单结构: +``` +
+ + +``` +控制器: +在该方法名前面加 `[HttpPost]` +该方法参数为 `(类型 变量名)` + +删除写一个新的方法 +按钮`` +进行删除然后返回首页 +#### 专项练习-Linq集成查询和Lambda表达式 + + +##### 基础练习 + +1. **查询特定元素** + 找出数组中等于5的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6 }; + ``` +![20241208170855](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241208170855.png) + +2. **查询特定范围的元素** + 找出数组中在2到8之间的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6 }; + ``` +![20241208171337](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241208171337.png) + +3. **查询并转换元素** + 将数组中的每个数字乘以2。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6 }; + ``` +![20241208172946](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241208172946.png) + +4. **查询特定属性的对象** + 找出所有名字以"王"开头的学生。 + + ```csharp + List students = new List + { + new Student {Id=1, Name = "王有才", Age = 21 }, + new Student {Id=2, Name = "王中王", Age = 22 }, + new Student {Id=3, Name = "张语嫣", Age = 23 }, + new Student {Id=4, Name = "詹宇航", Age = 35 }, + new Student {Id=5, Name = "郑雨良", Age = 26 }, + }; + ``` +![20241208180610](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241208180610.png) + +5. **查询并排序** + 找出所有年龄大于20岁的学生,并按年龄降序排列。 + + ```csharp + List students = new List + { + new Student {Id=1, Name = "王有才", Age = 21 }, + new Student {Id=2, Name = "罗婷", Age = 21 }, + new Student {Id=3, Name = "王中王", Age = 22 }, + new Student {Id=4, Name = "李子柒", Age = 22 }, + new Student {Id=5, Name = "张语嫣", Age = 23 }, + new Student {Id=6, Name = "詹宇航", Age = 35 }, + new Student {Id=7, Name = "郑雨良", Age = 26 }, + new Student {Id=8, Name = "欧文", Age = 26 }, + }; + ``` +![20241208180737](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241208180737.png) + +6. **查询并去重** + 找出数组中所有不重复的数字。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![20241208180855](https://bucket32703.oss-cn-beijing.aliyuncs.com/img32703/20241208180855.png) + +7. **查询第一个元素** + 找出数组中第一个大于3的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/202412057.png) + + +8. **查询最后一个元素** + 找出数组中最后一个小于7的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/202412058.png) + +9. **查询元素是否存在** + 检查数组中是否存在大于10的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/202412059.png) + +10. **查询元素的计数** + 计算数组中大于5的元素数量。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/202412059.png) + +11. **查询元素的总和** + 计算数组中所有元素的总和。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120511.png) + +12. **查询元素的最大值** + 找出数组中的最大值。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120512.png) + +13. **查询元素的最小值** + 找出数组中的最小值。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120513.png) + +14. **查询元素的平均值** + 计算数组中所有元素的平均值。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120514.png) + +15. **查询特定条件的元素** + 找出数组中能被3整除的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120515.png) + +##### 中级练习 + +16. **查询并选择特定属性** + 找出所有学生的姓名和年龄。 + + ```csharp + List students = new List + { + new Student {Id=1, Name = "王有才", Age = 21 }, + new Student {Id=2, Name = "罗婷", Age = 21 }, + new Student {Id=3, Name = "王中王", Age = 22 }, + new Student {Id=4, Name = "李子柒", Age = 22 }, + new Student {Id=5, Name = "张语嫣", Age = 23 }, + new Student {Id=6, Name = "詹宇航", Age = 35 }, + new Student {Id=7, Name = "郑雨良", Age = 26 }, + new Student {Id=8, Name = "欧文", Age = 26 }, + }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120516.png) + +17. **查询并分组** + 按年龄分组学生,并计算每个年龄组的学生数量。 + + ```csharp + List students = new List + { + new Student {Id=1, Name = "王有才", Age = 21 }, + new Student {Id=2, Name = "罗婷", Age = 21 }, + new Student {Id=3, Name = "王中王", Age = 22 }, + new Student {Id=4, Name = "李子柒", Age = 22 }, + new Student {Id=5, Name = "张语嫣", Age = 23 }, + new Student {Id=6, Name = "詹宇航", Age = 35 }, + new Student {Id=7, Name = "郑雨良", Age = 26 }, + new Student {Id=8, Name = "欧文", Age = 26 }, + }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120517.png) + +18. **查询并联结** + 联结学生和课程表,找出每个学生的所有课程。 + + ```csharp + List students = new List + { + new Student {Id=1, Name = "王有才", Age = 21 }, + new Student {Id=2, Name = "罗婷", Age = 21 }, + new Student {Id=3, Name = "王中王", Age = 22 }, + new Student {Id=4, Name = "李子柒", Age = 22 }, + new Student {Id=5, Name = "张语嫣", Age = 23 }, + new Student {Id=6, Name = "詹宇航", Age = 35 }, + new Student {Id=7, Name = "郑雨良", Age = 26 }, + new Student {Id=8, Name = "欧文", Age = 26 }, + }; + List courses=new List + { + new Course{StudentId=1,CourseName="英语"}, + new Course{StudentId=1,CourseName="数学"}, + new Course{StudentId=2,CourseName="语文"}, + new Course{StudentId=3,CourseName="物理"}, + new Course{StudentId=4,CourseName="化学"}, + new Course{StudentId=4,CourseName="生物"}, + new Course{StudentId=4,CourseName="语文"}, + }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/2024120518.png) + +19. **查询并反转** + 反转数组中的元素顺序。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205194707.png) + +20. **查询并填充** + 找出数组中第一个大于2的元素,并用它填充后面的所有位置。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205195443.png) + +21. **查询并排除** + 从数组中排除所有小于5的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205195642.png) + +22. **查询并填充默认值** + 如果数组中存在null值,用默认值0替换。 + + ```csharp + int?[] nullableNumbers = { 1, null, 3, null, 5 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205200029.png) + +23. **查询并转换类型** + 将字符串数组转换为整数数组。 + + ```csharp + string[] stringNumbers = { "1", "2", "3", "4" }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205200323.png) + + +24. **查询并使用OfType过滤** + 从对象数组中过滤出字符串类型的元素。 + + ```csharp + object[] objects = { "String", 123, "Another String", 456 }; + var result = objects.OfType().ToList(); + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205200523.png) + +##### 高级练习 + +25. **查询并使用Zip合并** + 合并两个数组,并创建一个包含元素对的新数组。 + + ```csharp + int[] numbers1 = { 1, 2, 3 }; + int[] numbers2 = { 4, 5, 6 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205201538.png) + +26. **查询并使用Range生成** + 生成一个包含1到10的整数数组。 + + ```csharp + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205201815.png) + +27. **查询并使用Repeat重复** + 重复一个元素多次,创建一个新数组。 + + ```csharp + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205202113.png) + +28. **查询并使用Take限制数量** + 从数组中取出前5个元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205202409.png) + +29. **查询并使用Skip跳过元素** + 跳过数组中的前3个元素,然后取出剩余的元素。 + + ```csharp + int[] numbers = { 1, 2, 3, 4, 5, 6,18,23,64,7,18,2,3 }; + ``` +![](https://gitee.com/shen-yulin20051127/imgs/raw/master/imgs/20241205202409.png) + + + + diff --git "a/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/\345\261\217\345\271\225\346\210\252\345\233\276 2024-11-17 220342.png" "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/\345\261\217\345\271\225\346\210\252\345\233\276 2024-11-17 220342.png" new file mode 100644 index 0000000000000000000000000000000000000000..98ea2533222a939240cb38b846c8ac12ba3ab269 Binary files /dev/null and "b/\346\235\234\344\270\200\345\215\232/\350\257\276\345\240\202\347\254\224\350\256\260/\345\261\217\345\271\225\346\210\252\345\233\276 2024-11-17 220342.png" differ