摘要:// 委托 // 一种方法的声明和定义,也就是方法的占位符 // 一般使用在 参数 和 属性中 int Add(int a,int b) { return a + b; } // 定义委托的三种方法 三个内定的委托 // action Func Predicate // 1. action 定义声明
阅读全文
摘要:// 集合 & 字典的初识 // 集合的使用 // 集合与数组比较类似,都用于存放一组值 // 数组的优劣势分析 // 1. 优势:数组在内存中是连续存储的,所以他的索引速度非常的快,而且赋值与修改元素也很简单 // 2. 劣势:在数组的连个数据之间插入数据很麻烦 在声明数组的时候,必须同时指明数组
阅读全文
摘要:// 原始字符串使用 三个引号(至少三对)包裹,ps: 引号单独占用一行 // 原始字符串使用变量需要加两个 $$"""{变量}""" string str = """ 原始 字符串 """;
阅读全文
摘要:什么是多态? 同一个事件发生在不同的对象上会产生不同的结果。 静态多态:1. 函数重载 2. 运算符重载 动态多态是通过抽象类和虚方法实现的
阅读全文
摘要:// 函数和方法 // 函数好比对象的动作行为 在定义函数的时候,职责(作用/功能)越单一越好 满足高内聚 低耦合的开发思路 // 变量的命名规则 小驼峰 // 函数的命名规则 大驼峰 动词开头 // 函数的参数 参数可以认为是外部需要函数帮忙处理的数据 外部通过传参的形式把需要处理的参数传递给函数
阅读全文
摘要:// 显式转换 (类型) /// (int)表示使用强制的显示转换,是一种类型转换,C#默认的整形是 int32 , /// 因此使用此方法转成int32 不遵循四舍五入,直截取整数部分 /// (int)5.12 结果是 5 /// Int.Parse() 指把 string 类型转换 int 类
阅读全文
摘要:· // 数组 /// 数组是一组相同类型的数据(ps:js中的数组可以不同类型) 访问通过索引访问数组元素 /// 数组的声明 要使用 new 使用 {} 来初始化数组元素 还需要指定数组的大小 /// // 声明了一个没有元素的数组 int[] iarr = new int[6]; // 规定了
阅读全文
摘要:// C# 中的新语法 switch 的简写 string str = "123"; string res = str switch { "1" => "1", "2" => "2", "3" => "3", _ => "default", };
阅读全文
摘要:// C# 运算符 // 表达式 表达式有操作数(operand)和运算符(operator)构成; // 常见的运算符 + - * / 和 new // x ?? y 如果x为null, 则计算机过为y否则计算结果为x; // 匿名函数 (lamba表达式) // 前置的 ++ 直接执行 后置的
阅读全文
摘要:// 空类型 null int iii; // 默认 0 bool bbb; // 默认 false bool? b; // 空值 null int? i; // 空值 null string str; // 默认 null 空值 str = null; string str1 = ""; // n
阅读全文
摘要:// 布尔类型 boll bool b = false; b = 1 == 1; // true bool b1 = 1 > 23; // false // 值类型 : 在代码中初始化类型的时候没有赋值 但是系统会自动赋值的叫值类型 // byte short int(default 0) long
阅读全文
摘要:// 浮点型数据 float double(双精度) // float f = 1.1; // ps:写小数的时候只要后面没有加上 f/F 默认是double类型 // 正确的定义 double d = 1.1; float f = 1.1F; float f1 = 1f; // f = d; //
阅读全文
摘要:// C# 中有四种整数类型 byte short int long byte bMax = byte.MaxValue; /// 255 最大值 byte bMin = byte.MinValue; /// 0 最小值 short sMax = short.MaxValue; // 32767 s
阅读全文
摘要:控制器部分: using Microsoft.AspNetCore.Mvc; using WebApplication1.IServices; using WebApplication1.Utility.SwaggerExt; namespace WebApplication1.Controller
阅读全文
摘要:#region 启用跨域访问 app.UseCors(builder => builder .AllowAnyMethod() .SetIsOriginAllowed(_ => true) .AllowAnyHeader() .AllowCredentials() ); #endregion app
阅读全文
摘要:/// <summary> /// 如果登录成功就返回电脑的进程信息 /// </summary> /// <returns></returns> [HttpPost] public LoginResponse Login(LoginRequest req) { if(req.UserName ==
阅读全文
摘要:使用地址参数传递(queryString)数据:eg:http://localhost:5063/WeatherForecast?age=123 /// <summary> /// GET方法 /// </summary> /// <returns></returns> [HttpGet(Name
阅读全文