摘要: for和foreach 循环是 C# 开发人员工具箱中最有用的构造之一。 在我看来,迭代一个集合比大多数情况下更方便。 它适用于所有集合类型,包括不可索引的集合类型(如 ,并且不需要通过索引访问当前元素)。 但有时,确实需要当前项的索引;这通常会使用以下模式之一: // foreach 中叠加 in 阅读全文
posted @ 2024-03-05 11:45 Best丶zhaotf 阅读(2) 评论(0) 推荐(0) 编辑
摘要: public class CustomRadixPointAttribute : ValidationAttribute { private readonly int _index; public CustomRadixPointAttribute(int index) { _index = ind 阅读全文
posted @ 2023-10-20 17:34 Best丶zhaotf 阅读(200) 评论(0) 推荐(0) 编辑
摘要: using Microsoft.Extensions.Hosting;using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Thre 阅读全文
posted @ 2022-07-14 16:20 Best丶zhaotf 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 目录前言环境准备.NETCore项目准备1.首先我们先创建一个空的ASP.NETCoreWeb应用2.我们可以先在本地将项目构建成镜像看看效果3.接下来我们将镜像run起来,构造出一个容器:Li... 目录 前言 环境准备 .NET Core项目准备 1.首先我们先创建一个空的ASP.NET Cor 阅读全文
posted @ 2022-06-30 16:46 Best丶zhaotf 阅读(3005) 评论(3) 推荐(0) 编辑
摘要: 参数: { dt:"2022-03-02 03:16:26" } 接收:DateTime message:"参数与参数类型不匹配" 有两种 第一种: 第一步:自定义DateTime解析类 public class DateTimeConverter : JsonConverter<DateTime> 阅读全文
posted @ 2022-05-18 16:31 Best丶zhaotf 阅读(243) 评论(0) 推荐(0) 编辑
摘要: List<User> users = new List<User>(); users.Add(new User("张三", "永丰路299号")); users.Add(new User("张三", "上地西路8号"));//重复项,去重后将删掉 users.Add(new User("李四", " 阅读全文
posted @ 2022-04-14 10:53 Best丶zhaotf 阅读(10259) 评论(0) 推荐(0) 编辑
摘要: 一、简介前后端分离的站点一般都会用jwt或IdentityServer4之类的生成token的方式进行登录鉴权。这里要说的是小项目没有做前后端分离的时站点登录授权的正确方式。二、传统的授权方式这里说一下传统授权方式,传统授权方式用session或cookies来完成。 1、在请求某个Action之前 阅读全文
posted @ 2021-11-26 16:57 Best丶zhaotf 阅读(806) 评论(0) 推荐(0) 编辑
摘要: 进行依赖注入有三种方式: 1、构造方法依赖注入 public class StupidStudent { private SmartStudent smartStudent; public StupidStudent(SmartStudent smartStudent) { this.smartSt 阅读全文
posted @ 2020-09-29 21:25 Best丶zhaotf 阅读(7086) 评论(0) 推荐(0) 编辑
摘要: 思考:为什么要使用异步编程? 我们先看看同步方法和异步方法之前在程序中执行的逻辑: 1. 同步方法 static void Main(string[] args) { Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ms 阅读全文
posted @ 2020-07-11 10:23 Best丶zhaotf 阅读(503) 评论(0) 推荐(0) 编辑
摘要: 一、什么是OAuth OAuth是一个关于授权(Authorization)的开放网络标准,目前的版本是2.0版。注意是Authorization(授权),而不是Authentication(认证)。用来做Authentication(认证)的标准叫做openid connect,我们将在以后的文章 阅读全文
posted @ 2020-06-23 12:54 Best丶zhaotf 阅读(449) 评论(3) 推荐(0) 编辑