
C#
C#
xxxxxue
快乐的小码农
展开
-
.Net / C# 繁体中文 与 简体中文 互相转换, 支持地方特色词汇
支持 “繁,简” 的互相转换, 支持多个地区常用词汇的转换, 还支持 日文的新旧转换.Nuget 搜索 “OpenCCNET”,这里只举例 繁体 转 简体, 其他的类似。OpenCC 在 .Net 中的实现。注意别找错, 好多库的名字都差不多。原创 2025-01-30 16:36:07 · 1010 阅读 · 0 评论 -
.Net / C# 分析文件编码 并将 各种编码格式 转为 另一个编码格式 ( 比如: GB2312→UTF-8, UTF-8→GB2312)
【代码】.Net / C# 分析文件编码 并将 各种编码格式 转为 另一个编码格式 ( 比如: GB2312→UTF-8, UTF-8→GB2312)原创 2025-01-30 00:26:08 · 362 阅读 · 0 评论 -
C# .Net 发布后,把dll全部放在一个文件夹中,让软件目录更整洁
之前找到一个修改 exe 中 DLL地址 的方法, 不太好使,虽然能正确启动, 但无法改变 exe 的工作目录,这就影响了.Net 中很多获取 exe 执行目录来拼接的地址 ( 相对路径 ),比如 wwwroot 和 代码中相对目录还有一些复制到目录的普通文件 等等,它们的地址都会指向原来 exe 的目录, 而不是自定义的 “lib” 目录,根本原因就是没有修改 exe 的工作目录这次来搞一个启动程序,把 .net 的所有东西都放在一个文件夹,在文件夹同级的目录制作一个 exe.原创 2024-02-22 21:48:56 · 1219 阅读 · 0 评论 -
c# 释放所有嵌入资源, 到某个本地文件夹
【代码】c# 释放所有嵌入资源, 到某个本地文件夹。原创 2024-01-20 16:41:14 · 810 阅读 · 0 评论 -
EFCore 中 DateTimeOffset 报错 System.InvalidOperationException
System.InvalidOperationException:The LINQ expression 'DbSet().Where(t => t.CreatedTime >= 2022/10/3 10:20:30)' could not be translated.Either rewrite the query in a form that can be translated,or switch to client evaluation explicitly by inserting a cal原创 2023-04-25 13:53:45 · 1029 阅读 · 0 评论 -
C# Winform DataGridView 自适应
布局 中设置Anchor = Top, Bottom, Left, Right (设置上下左右 是否锁定 外边距)AutoSizeColumnsMode = AllCells (列 自适应宽度)AutoSizeRowsMode = AllCells (行 自适应高度)原创 2022-01-02 22:50:15 · 2030 阅读 · 0 评论 -
C# Newtonsoft.Json,System.Text.Json ,无需定义类,直接动态获取Json值
Newtonsoft.Jsonvar data = JsonConvert.DeserializeObject<JObject>(content);if (data != null){ // 读取 var id = Convert.ToInt32(data["id"]); // 如果为空,转int32结果为0 var name = data["name"]?.ToString(); var url = data["url"]?.原创 2021-12-06 20:17:47 · 2429 阅读 · 1 评论 -
C# 读写内存
【代码】C# 读写内存。原创 2021-11-25 20:22:30 · 2731 阅读 · 0 评论 -
Winform处理全局异常
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace Main{ internal static class Program { [STAThread] static void Main() { try原创 2021-11-23 15:34:15 · 709 阅读 · 0 评论 -
C#使用HttpListener构建一个简易的Http服务器
调用using System;using System.Threading.Tasks;using Demo.Services;using Microsoft.Extensions.Hosting;namespace Demo{ internal static class Program { public async static Task Main(string[] args) { FrameWorkInfoServic原创 2021-09-14 15:55:47 · 872 阅读 · 0 评论 -
C# EntityFrameworkCore自动修改CreateTime,UpdateTime
其他数据库Model继承BaseDbModelusing System;using System.ComponentModel.DataAnnotations;using Microsoft.EntityFrameworkCore;using Newtonsoft.Json;namespace Demo.Model.Base{ public class BaseDbModel { [Key] public int Id { get; set; } .原创 2021-09-14 15:30:49 · 1060 阅读 · 1 评论 -
C# EntityFrameworkCore 分页
使用public static PagedList<FrameWorkInfo> GetFrameWorks(int pageIndex = 1, int pageSize = 20){ var db = new DefaultDbContext(); return db.FrameWorkInfos .Where(a => a.IsDeleted == false) .ToPagedList(pageIndex, pageSize);原创 2021-09-14 15:22:49 · 778 阅读 · 1 评论 -
C# .NetCore Console控制台项目添加Ctrl+C停止程序
Windows , Linux ,Docker 都有效NugetMicrosoft.Extensions.Hosting 5.0.0代码方案1using System;using Microsoft.Extensions.Hosting;namespace Demo{ internal static class Program { public static void Main(string[] args) {原创 2021-09-14 14:36:45 · 1075 阅读 · 0 评论 -
AspNetCore SignalR : Json 实体循环引用问题解决方案
大概报错信息一般是 两个实体 互相引用造成的死循环, (你中有我,我中有你,程序会一直递归下去)设置 忽略引用, 即可解决System.Text.Json.JsonException: A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 64. Consider usin原创 2020-12-27 22:54:47 · 1155 阅读 · 0 评论 -
Docsify 侧边栏 : 自动生成sidebar与子目录sidebar
Docsify 侧边栏 : 自动生成sidebar与子目录sidebarhttps://github.com/xxxxue/Docsify-Build-Sidebar原创 2020-12-10 17:46:32 · 5323 阅读 · 3 评论