C#
qq_45659882
这个作者很懒,什么都没留下…
展开
-
C#对List列表中的对象分组
{}原创 2022-09-08 12:57:34 · 527 阅读 · 0 评论 -
基于 .NET 6 的ASP.NET Core启动地址配置方法及优先级顺序
.net6启动端口方式原创 2022-04-02 11:00:28 · 1920 阅读 · 0 评论 -
最恶心的数据转换,对象Key不同
Dictionary<string, List<AddTZCity>> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, List<AddTZCity>>>(aas);原创 2022-04-01 16:25:27 · 72 阅读 · 0 评论 -
Linux守护进程
Linux的Daemon管理路径:cd /etc/systemd/system新建一个service配置文件:vi my-auth.servicevi编辑器中编写的配置信息:[Unit]Description=Auth .NET Web API App running on Ubuntu[Service]WorkingDirectory=/home/authExecStart=/usr/bin/dotnet /home/auth/AuthServer.Host.dlllRe原创 2022-03-31 13:57:15 · 246 阅读 · 0 评论 -
【.NET 6】Linux环境部署代码 超级详细教程(附代码)
进入到服务器后的正文:1. yum update2. yum install net-tools3. 注册镜像地址sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm4. 安装 ASP.NET Core SDKsudo yum updatesudo yum install dotnet-sdk-6.05. 关闭防火墙systemctl disable f原创 2022-03-30 13:47:04 · 2004 阅读 · 0 评论 -
C#List<操作>
同一个list集合,根据某个字段去重gradeSubjectItem teacher = teacherInfos.Where((x, i) => teacherInfos.FindIndex(z => z.guid == x.guid) == i).ToList();不同list集合,根据另一个包含的内容去重//要被去重的list集合detailInfoList//所需要去重的一些数据List<string> deletelist = new List&原创 2022-02-24 16:50:26 · 205 阅读 · 0 评论 -
Loading local data is disabled; this must be enabled on both the client and server sides
mysql使用文件导入数据是报错:Loading local data is disabled; this must be enabled on both the client and server sides临时解决办法:命令行输入mysql登录命令:mysql --local-infile=1 -u root -p 设置变量:SET GLOBAL local_infile=1;查看变量:show global variables like 'local_infile';mys原创 2022-02-21 15:47:06 · 603 阅读 · 0 评论 -
c# 泛型通过反射获取属性值和修改属性值
Type entityType = typeof(T); //T泛型 //通过属性名获取属性值 “CenterCode”属性名称 PropertyInfo proInfo = entityType.GetProperty("CenterCode"); var result = proInfo.GetValue(t); proInfo.SetValue(t,3); result = pr...原创 2022-01-17 14:13:53 · 1039 阅读 · 0 评论 -
.net5控制台程序使用IOC容器
创建控制台应用 class Program { static void Main(string[] args) { Host.CreateDefaultBuilder().ConfigureServices((builder, services) => { var config = builder.Configuration; serv原创 2022-01-04 15:55:18 · 687 阅读 · 0 评论 -
CSRedis简单的使用
安装CSRedis直接使用Visual Studio中的Nuget包管理器搜索安装开始之前使用连接字符串创建redis实例,执行RedisHelper.Initialization()进行初始化。var csredis = new CSRedisClient("127.0.0.1:6379,password=YourPassword");RedisHelper.Initialization(csredis);如果你没有给redis设置密码,那么直接写上ip就行,否则的话要把pa原创 2021-12-31 13:50:53 · 906 阅读 · 0 评论 -
c#导出excel文件,以及出现解决方法
using OfficeOpenXml;using System.IO;static void Main(string[] args){ int[] testData = { 1, 2, 3 }; ExcelWorksheet workSheet; using (var p = new ExcelPackage()) { workSheet = p.Workbook.Worksheets.Add("测试数据"); workS...原创 2021-12-28 11:18:05 · 1185 阅读 · 0 评论 -
解决.net中报错,BinaryFormatter serialization and deserialization are disabled within this application
最近在项目开发过程中调用类库出现这个问题,查了下文档,发现是微软在新版本中禁用了BinaryFormatter的Deserialize,具体的一些信息可以看官方的文档解决方案BinaryFormatter 安全指南 | Microsoft Docs不过文档中只给出了几个替代方案,就是使用XmlSerializer、DataContractSerializer、BinaryReader和BinaryWriter、System.Text.JsonAPI 这几种方法替代由于我这边不想对原有的引用.原创 2021-12-22 10:57:55 · 3297 阅读 · 0 评论 -
.Net5使用redis
为什么选择CSRedisCoreServiceStack.Redis 是商业版,免费版有限制;StackExchange.Redis 是免费版,但是内核在 .NETCore 运行有问题经常 Timeout,暂无法解决;CSRedis于2016年开始支持.NETCore一直迭代至今,实现了低门槛、高性能,和分区高级玩法的.NETCore redis-cli SDK;在v3.0版本更新中,CSRedis中的所有方法名称进行了调整,使其和redis-cli保持一致,如果你熟悉redis-...原创 2021-12-21 17:34:29 · 464 阅读 · 0 评论 -
.net5缓存使用地址
https://easycaching.readthedocs.io/en/latest/Castle/原创 2021-12-21 17:28:38 · 87 阅读 · 0 评论 -
C#操作redis
Redis 是一个非关系型高性能的key-value数据库。在部分场合可以对关系数据库起到很好的补充作用。它提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang等客户端,使用很方便。redis提供五种数据类型:string,hash,list,set及zset(sorted set)。好了,话不多说,先安装redis吧。我这里提供的版本是64位的3.2.1.00https://files.cnblogs.com...原创 2021-12-15 17:47:16 · 2499 阅读 · 0 评论 -
.net5获取启动程序下的路径,C#获取程序下的路径
一、C#获取当前路径的方法:1..net5获取启动程序下的路径 :System.AppDomain.CurrentDomain.BaseDirectory;1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName-获取模块的完整路径。2. System.Environment.CurrentDirectory-获取和设置当前目录(该进程从中启动的目录)的完全限定目录。3. System.IO.Dire.原创 2021-12-06 17:06:46 · 1045 阅读 · 0 评论