01 2024 档案
摘要:新增的 System.Buffers.SearchValues类,可以用来进行字符串的查找和匹配,相比较 string 类型的操作,性能有大幅提升,下面还是用 BenchmarkDotNet 进行测试: BenchmarkRunner.Run<SearchValuesTest>(); Console
阅读全文
摘要:1、在 8 中对随机数类 Random 提供了 GetItems() 方法,可以根据指定的数量在提供的一个集合中随机抽取数据项生成一个新的集合: ReadOnlySpan<string> colors = new[]{"Red","Green","Blue","Black"}; string[] t
阅读全文
摘要:调用 API 直接获取到对象现在有一个接口返回如下图中的数据: 如果是在 8 以前的版本中获取该接口的数据,需要先获取到接口内容,然后进行反序列化,代码如下 const string RequestUri = "http://localhost:5145/user"; using var clien
阅读全文
摘要:1.概要 在.NET8中C#的新增特性,System.ComponentModel.DataAnnotations 命名空间包括用于云原生服务中的验证场景的新数据验证特性。 虽然预先存在的 DataAnnotations 验证程序适用于典型的 UI 数据输入验证(例如窗体上的字段),但新特性旨在验证
阅读全文
摘要:1、创建一个winform程序,安装PdfSharp 1.50.5147 2、添加一个按钮,代码如下 using PdfSharp.Drawing; using PdfSharp.Pdf; using System; using System.IO; using System.Windows.For
阅读全文
摘要:1、添回操作类文件AppSettings.cs using Microsoft.Extensions.Configuration.Json; namespace YYApi.Helper { /// <summary> /// appsettings.json操作类 /// </summary> p
阅读全文
摘要:1、创建一个winform项目 2、创建websocket服务端类WebSocket_Service.cs 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using Syste
阅读全文
摘要:采用rem网页自适应背景也自适应,设置background-size 属性 background-size 属性规定背景图像的尺寸 div { background:url(img_flwr.gif); background-size:1rem 1rem; background-repeat:no-
阅读全文
摘要:1、项目用到依赖注入参考: https://www.cnblogs.com/handsomeziff/p/16390502.html 2、新建ICaching接口 using Microsoft.Extensions.Caching.Distributed; namespace YYApi.Cach
阅读全文
摘要:分辨率大于540px的时候,flexible限制为540,一般的手机显示没有问题,但对于大于540的竖屏屏幕,可能右边就会留白。我想让横屏的时候限制在540,竖屏的时候根据页面实际宽度自适应,解决方法如下: 1、安装 npm install lib-flexible --save 2、为了避免每次安
阅读全文
摘要:dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSiz
阅读全文