老人言:尽量用异步

官方和老人言,asp.net core中尽量用异步,为什么呢?接下来是个小demo,看看同步异步的差别吧,或许通过这个demo,就明白官方和老人的良苦用心了。

1、创建一个sql server的表

CREATE TABLE [dbo].[Students]([StuNo] [varchar](50) NOT NULL,[Name] [varchar](50) NULL,[CardID] [varchar](18) NULL,[Sex] [varchar](4) NULL,[Birthday] [datetime] NULL,[ClassID] [int] NULL,CONSTRAINT [PK_dbo.Students] PRIMARY KEY CLUSTERED 
([StuNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

2、创建一个asp.net core api项目,5.0的

using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;namespace AsyncWebAPI.Controllers
{[ApiController][Route("[controller]")]public class StudentController : ControllerBase{private readonly ILogger<StudentController> _logger;public StudentController(ILogger<StudentController> logger){_logger = logger;}[HttpDelete("/deleteall")]public bool DeleteAll(){_logger.LogInformation("删除全部");using var con = new SqlConnection("server=.;database=TestManageDB;uid=sa;pwd=sa;");var sql = @"delete from  [dbo].[Students]";var cmd = new SqlCommand(sql, con);con.Open();var result = cmd.ExecuteNonQuery();con.Close();return true;}[HttpPost("/addstudent")]public Student AddEntity([FromBody] Student student){_logger.LogInformation("同步添加");return SavaEntity(student);}Student SavaEntity(Student student){student.StuNo = Guid.NewGuid().ToString();using var con = new SqlConnection("server=.;database=TestManageDB;uid=sa;pwd=sa;");var sql = @"INSERT INTO [dbo].[Students]([StuNo],[Name],[CardID],[Sex],[Birthday],[ClassID])VALUES(@StuNo,@Name,@CardID,@Sex,@Birthday,@ClassID)";var cmd = new SqlCommand(sql, con);cmd.Parameters.Add(new SqlParameter { ParameterName = "@StuNo", Value = student.StuNo, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@Name", Value = student.Name, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@CardID", Value = student.CardID, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@Sex", Value = student.Sex, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@Birthday", Value = student.Birthday, SqlDbType = System.Data.SqlDbType.DateTime });cmd.Parameters.Add(new SqlParameter { ParameterName = "@ClassID", Value = student.ClassID, SqlDbType = System.Data.SqlDbType.Int });con.Open();var result = cmd.ExecuteNonQuery();con.Close();return student;}[HttpPost("/addstudentasync")]public async Task<Student> AddEntityAsync([FromBody] Student student){_logger.LogInformation("异步添加");return await SavaEntityAsync(student);}async Task<Student> SavaEntityAsync(Student student){student.StuNo = Guid.NewGuid().ToString();using var con = new SqlConnection("server=.;database=TestManageDB;uid=sa;pwd=sa;");var sql = @"INSERT INTO [dbo].[Students]([StuNo],[Name],[CardID],[Sex],[Birthday],[ClassID])VALUES(@StuNo,@Name,@CardID,@Sex,@Birthday,@ClassID)";var cmd = new SqlCommand(sql, con);cmd.Parameters.Add(new SqlParameter { ParameterName = "@StuNo", Value = student.StuNo, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@Name", Value = student.Name, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@CardID", Value = student.CardID, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@Sex", Value = student.Sex, SqlDbType = System.Data.SqlDbType.VarChar });cmd.Parameters.Add(new SqlParameter { ParameterName = "@Birthday", Value = student.Birthday, SqlDbType = System.Data.SqlDbType.DateTime });cmd.Parameters.Add(new SqlParameter { ParameterName = "@ClassID", Value = student.ClassID, SqlDbType = System.Data.SqlDbType.Int });await con.OpenAsync();var result = await cmd.ExecuteNonQueryAsync();await con.CloseAsync();return student;}}public class Student{public string StuNo { get; set; }public string Name { get; set; }public string CardID { get; set; }public string Sex { get; set; }public DateTime Birthday { get; set; }public int ClassID { get; set; }}
}

3、创建一个控制台程序,了是.net core 5.0的

using Newtonsoft.Json;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;namespace AsyncRquestClient
{class ProgramAsync{static int times = 100;static async Task Main(string[] args){while (true){Console.WriteLine("输入循环次数");times = int.Parse(Console.ReadLine());#region 同步Console.WriteLine("-----------------同步调同步API------------------");SyncCallSyncAPI();Console.ReadLine();Console.WriteLine("-----------------同步调异步API------------------");SyncCallAsyncAPI();Console.ReadLine();Console.WriteLine("-----------------TaskFactory同步调同步API------------------");TaskFactorySyncCallSyncAPI();Console.ReadLine();Console.WriteLine("-----------------TaskFactory同步调异步API------------------");TaskFactorySyncCallAsyncAPI();Console.ReadLine();#endregion#region 异步Console.WriteLine("-----------------异步调异步API------------------");await AsyncCallAsyncAPI();Console.ReadLine();Console.WriteLine("-----------------异步调同步API------------------");await AsyncCallSyncAPI();Console.ReadLine();Console.WriteLine("-----------------TaskFactory异步调异步API------------------");await TaskFactoryAsyncCallAsyncAPI();Console.ReadLine();Console.WriteLine("-----------------TaskFactory异步调同步API------------------");await TaskFactoryAsyncCallSyncAPI();Console.ReadLine();#endregion}}#region 异常/// <summary>/// 异步调异步API/// </summary>/// <returns></returns>async static Task AsyncCallAsyncAPI(){var r = DeleteAllAsync().Result;Console.WriteLine($"异步调异步API开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudentasync");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = response.Content.ReadAsStringAsync().Result;Console.WriteLine("同步调同步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}}}/// <summary>/// TaskFactory异步调异步API/// </summary>/// <returns></returns>static async Task TaskFactoryAsyncCallAsyncAPI(){var r = await DeleteAllAsync();Console.WriteLine($"TaskFactory异步调异步开API始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){await Task.Factory.StartNew(async () =>{try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudentasync");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = await response.Content.ReadAsStringAsync();Console.WriteLine("异步调异步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}});}}/// <summary>/// 异步调同步API/// </summary>/// <returns></returns>async static Task AsyncCallSyncAPI(){var r = DeleteAllAsync().Result;Console.WriteLine($"异步调同步API开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudent");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = response.Content.ReadAsStringAsync().Result;Console.WriteLine("同步调同步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}}}/// <summary>/// TaskFactory异步调同步API/// </summary>/// <returns></returns>static async Task TaskFactoryAsyncCallSyncAPI(){var r = await DeleteAllAsync();Console.WriteLine($"TaskFactory异步调同步API开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){await Task.Factory.StartNew(async () =>{try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudent");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = await response.Content.ReadAsStringAsync();Console.WriteLine("异步调异步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}});}}#endregion#region 同步/// <summary>/// 同步调同步API/// </summary>static void SyncCallSyncAPI(){var r = DeleteAllAsync().Result;Console.WriteLine($"同步调同步开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudent");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = client.SendAsync(request).Result;if (response.IsSuccessStatusCode){var content = response.Content.ReadAsStringAsync().Result;var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = response.Content.ReadAsStringAsync().Result;Console.WriteLine("同步调同步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}}}static void TaskFactorySyncCallSyncAPI(){var r = DeleteAllAsync().Result;Console.WriteLine($"TaskFactory异步调同步API开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){var result = Task.Factory.StartNew(async () =>{try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudent");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = await response.Content.ReadAsStringAsync();Console.WriteLine("异步调异步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}}).Result;}}/// <summary>/// 同步调异步API/// </summary>static void SyncCallAsyncAPI(){var r = DeleteAllAsync().Result;Console.WriteLine($"同步调异步开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudentasync");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = client.SendAsync(request).Result;if (response.IsSuccessStatusCode){var content = response.Content.ReadAsStringAsync().Result;var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = response.Content.ReadAsStringAsync().Result;Console.WriteLine("同步调异步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}}}static void TaskFactorySyncCallAsyncAPI(){var r = DeleteAllAsync().Result;Console.WriteLine($"TaskFactory异步调同步API开始时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")}");for (int i = 1; i <= times; i++){var result = Task.Factory.StartNew(async () =>{try{var student = new Student { Name = "张三" + i, Birthday = DateTime.Now, CardID = "C0000" + i, ClassID = 1, Sex = "男" };using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Post, "addstudentasync");request.Content = new StringContent(JsonConvert.SerializeObject(student), Encoding.UTF8, "application/json");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var stu = JsonConvert.DeserializeObject<Student>(content);}else{var content = await response.Content.ReadAsStringAsync();Console.WriteLine("异步调异步添加错误返回值:" + content);}}catch (Exception exc){Console.WriteLine(exc.Message);}}).Result;}}#endregionstatic async Task<bool> DeleteAllAsync(){using var client = new HttpClient();client.BaseAddress = new Uri("https://localhost:5001");var request = new HttpRequestMessage(HttpMethod.Delete, "deleteall");var response = await client.SendAsync(request);if (response.IsSuccessStatusCode){var content = await response.Content.ReadAsStringAsync();var result = JsonConvert.DeserializeObject<bool>(content);return result;}else{var content = await response.Content.ReadAsStringAsync();Console.WriteLine("删除错误返回值:" + content);return false;}}}public class Student{public string StuNo { get; set; }public string Name { get; set; }public string CardID { get; set; }public string Sex { get; set; }public DateTime Birthday { get; set; }public int ClassID { get; set; }}}

4、在sql查询分析器中用这里的语句采集结果

--检查记录数是否完整
select count(*) from students;
--查询时间隔
select datediff(
millisecond,
(select min(birthday) as mi from students),
(select max(birthday) as ma from students)
);

结果如下:

1000次请求

同步调同步API

同步调异步API

TaskFactory同步调同步API

TaskFactory同步调异步API

异步调异步API

异步调同步API

TaskFactory异步调异步API

TaskFactory异步调同步API

1次(毫秒)

3190

3574

390

374

3393

3140

356

387

2次(毫秒

3194

3324

386

454

3370

3153

477

356

3次(毫秒

3350

3343

443

397

3323

3196

417

406

4次(毫秒

3207

3340

360

423

3206

3083

433

403

5次(毫秒

3214

3347

426

490

3167

3136

430

387

平均

3231

3385.6

401

427.6

3291.8

3141.6

422.6

387.8

客户端调用,异步优势明显;在所有的调用中,服务端的同步要优于异步。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/305923.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql函数保留小数_MySql自定义函数-关于保留小数位的特殊需求

背景昨天&#xff0c;关于价格详情接口又来了一个小需求&#xff0c;而且有点特别。价格显示&#xff1a;改为保留两位小数&#xff0c;没错&#xff0c;就是保留两位小数。大家是不是想说这没啥特别的。。。数据库都有函数搞定了。例如四舍五入的ROUND(x,d)&#xff0c;直接截…

整合.NET WebAPI和 Vuejs——在.NET单体应用中使用 Vuejs 和 ElementUI

.NET简介.NET 是一种用于构建多种应用的免费开源开发平台&#xff0c;例如&#xff1a;Web 应用、Web API 和微服务云中的无服务器函数云原生应用移动应用桌面应用1). Windows WPF2). Windows 窗体3). 通用 Windows 平台 (UWP)游戏物联网 (IoT)机器学习控制台应用Windows 服务跨…

python 进程池_python进程池

当需要创建的子进程数量不多时&#xff0c;可以直接利用multiprocessing中的Process动态成生多个进程&#xff0c;但如果是上百甚至上千个目标&#xff0c;手动的去创建进程的工作量巨大&#xff0c;此时就可以用到multiprocessing模块提供的Pool方法。初始化Pool时&#xff0c…

【gRPC】 在.Net core中使用gRPC

最近在学习.net core的微服务体系架构。微服务之间的通信常常通过gRPC进行同步通信&#xff0c;但是需要注意的是&#xff0c;大多数微服务之间的通信是通过事件总线进行异步通信。在微软介绍.net微服务体系架构的项目eShop中&#xff0c;微服务之间进行同步通信的场景很多&…

disconf mysql_Docker搭建disconf环境,三部曲之三:细说搭建过程

Docker下的disconf实战全文链接细说搭建过程在前两章中&#xff0c;我们利用远程或本地的镜像&#xff0c;快速体验了本地启动disconf的过程&#xff0c;本章我们一起来分析和梳理整个定制和搭建过程&#xff0c;了解这些后&#xff0c;我们就能根据自己的需要来定制本地的disc…

AgileConfig-如何使用AgileConfig.Client读取配置

前面的文章都是介绍AgileConfig服务端已经控制台是如何工作、如何使用的&#xff0c;其实AgileConfig还有一个重要的组成部分&#xff1a;AgileConfig.Client。AgileConfig.Client是使用C#编写的一个类库&#xff0c;只有使用它才能跟AgileConfig的服务端配合工作实现实时推送配…

mysql导入数据提前修改字段_Mysql一些导入导出数据库,添加修改字段命令_MySQL...

bitsCN.comMysql 导出数据库表包含数据命令&#xff1a;mysqldump -uroot -proot abc >/var/abc.sql;(mysql用户名&#xff1a;root 密码root 数据库&#xff1a;abc 导出到&#xff1a;/var/abc.sql)Mysql 导出数据库表不包含数据命令&#xff1a;mysqldump -uroot -proot …

轻量级 Kubernetes K3s - Github热点

轻量级 Kubernetes k3sstar: 15.5kK3s是完全符合生产要求的Kubernetes发行版, 安装简单&#xff0c;可用于生产&#xff0c;整个二进制文件小于100M&#xff0c;作为单一文件打包部署&#xff0c;优势在于&#xff0c;你只需几秒钟就可以得到一个完全成熟的Kubernetes集群。htt…

java 固定长度队列_如何彻底搞懂 Java 数据结构?|CSDN 博文精选

作者 | 张振华.Jack责编 | 郭芮出品 | CSDN 博客本文和大家一起来重温《Java数据结构》经典之作。Java数据结构要理解Java数据结构&#xff0c;必须能清楚何为数据结构&#xff1f;数据结构&#xff1a;Data_Structure&#xff0c;它是储存数据的一种结构体&#xff0c;在此结构…

IdentityServer4 之 Resource Owner Password Credentials 其实有点尴尬

前言接着IdentityServer4的授权模式继续聊&#xff0c;这篇来说说 Resource Owner Password Credentials授权模式&#xff0c;这种模式在实际应用场景中使用的并不多&#xff0c;只怪其太开放啦&#xff0c;直接在客户端上拿着用户名和密码就去授权服务器获取AccessToken&#…

存储过程mysql报错1271_mysqldump备份失败以及解决方法汇总

mysqldump备份失败以及解决方法汇总〇 mysqldump: Error: Query execution was interrupted, maximum statement execution time exceeded when trying to dump tablespaces〇 mysqldump: Error 3024: Query execution was interrupted, maximum statement execution time exce…

Xamarin使XRPC实现接口/委托远程调用

在之前的文章中已经介绍如何使用Beetlex.XRCP组件进行接口/委托远程调用&#xff1b;由于组件BeetleX.XRPC.Clients支持.NETStandard2&#xff0c;因此Xamarin同样可以使用它来实现基于接口/委托的数据交互通讯。接下来通过Xamarin实现一个简单的移动程序&#xff0c;并通过XRP…

mysql 拷贝安装_Mysql的安装和主从复制

安装mysql服务步骤一&#xff1a;首先下载mysql的yum源配置 &#xff0c;下载mysql的yum源wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm步骤二&#xff1a;安装mysql的yum源yum -y install mysql57-community-release-el7-11.noarch.rpm步骤三&…

浅谈CLR基础知识

中午的时候&#xff0c;有一个小伙伴问我&#xff0c;CLR到底是进程还是线程&#xff0c;它和自己写的程序是怎么关联的。这一问&#xff0c;直接把我问懞了。下面我尝试用简单的语言来描述这个问题&#xff0c;有的地方无法讲的太细&#xff08;不然内容会太多&#xff09;&am…

mysql打开无法控制_MySQL不能启动和停止 MySQL各种解决方法教程

MySQL不能启动和停止 MySQL各种解决方法教程本文章总结了种MySQL无法启动、无法停止解决办法&#xff0c;包括在windows系统,linux系统中mysql不能启动与停止的解决办法&#xff0c;有需了解的朋友可进入参考。解决无法启动A、先使用命令C:/Program files/mysql/bin/mysqladmin…

NHibernate中的SchemaExport

昨天&#xff0c;在看hibernate文档的时候&#xff0c;看到了这样一段&#xff1a; You should now create this table in your database manually, and later read Chapter 15, Toolset Guide if youwant to automate this step with the SchemaExport tool. This tool can …

Asp.Net Core使用Skywalking实现分布式链路追踪

介绍Skywalking 是 Apache 基金会下面的一个开源 APM 项目&#xff0c;是一套(APM)分布式追踪系统&#xff0c;提供了很多数据存储列如&#xff1a;Mysql&#xff0c;H2&#xff0c;Elasticsearch7 等。其中APM 全称是应用性能监测软件&#xff0c;主要是用来处理以及追踪分布式…

python 里什么时候缩进_python什么时候缩进

Python中的缩进(Indentation)决定了代码的作用域范围。这一点和传统的c/c有很大的不同(传统的c/c使用花括号花括号{}符决定作用域的范围&#xff1b;python使用缩进空格来表示作用域的范围&#xff0c;相同缩进行的代码是处于同一范围)。每行代码中开头的空格数(whitespace)用于…

Hey, everybody!

今天有一位MVP朋友问我是否想做MVP&#xff0c;我想了半天&#xff0c;还是觉得有机会就要尝试&#xff0c;失败了也没什么大不了的。所以最后决定要参加这么一次活动&#xff0c;虽然是自不量力&#xff0c;也要搏一搏啦&#xff01;如果说大家都能够来推荐我一下多好啊&#…

C# 9 新特性 —— 补充篇

C# 9 新特性 —— 补充篇Intro前面我们分别介绍了一些 C# 9 中的新特性&#xff0c;还有一些我觉得需要了解一下的新特性&#xff0c;写一篇作为补充。Top-Level Statements在以往的代码里&#xff0c;一个应用程序必须要有 Main 方法才能运行&#xff0c;从 C# 9 开始&#xf…