随笔分类 - C#
leaning C#
摘要:public class TestABC { public int A = 0; public int B = 0; public static bool operator ==(TestABC a, TestABC b) { return true; } public static bool op
阅读全文
摘要:<Grid x:Name="loadingMask" Background="#66000000" Visibility="Visible"> <Ellipse Width="40" Height="40" Stroke="White" StrokeThickness="4" StrokeDashA
阅读全文
摘要:下面来逐行、深入讲解 DynamicMaxLengthAttribute 的真实工作机制,非常值得理解。 ✅ 整体作用(一句话) ABP 用 反射修改 MaxLengthAttribute 的私有字段 <Length>k__BackingField,从而动态设置最大长度。 ✅ 代码逐行深度解析 pu
阅读全文
摘要:_currentUser = Substitute.For<ICurrentUser>(); 这是 NSubstitute(一个 .NET 单元测试 mock 框架)中的标准用法,用来“创建一个假的 ICurrentUser 实例”。 下面详细解释它的逻辑。 ✅ 到底发生了什么? Substitut
阅读全文
摘要:ServiceCollection 和 ServiceProvider 是 .NET 依赖注入系统中的两个核心概念,但它们的职责完全不同。理解这两个概念对看懂 ASP.NET Core / ABP 框架的 DI 机制非常重要。 下面用非常清晰、分层方式给你解释: ✔️ 一句话解释 ServiceCo
阅读全文
摘要:来给你几个层次递进的 LINQ Join 示例,从最基础的单表连接到多表、对象导航、分组连接全部覆盖。 以下示例均基于 C# + LINQ to Objects(适用于 EF Core / ABP 的仓储查询场景)。 🌱 一、基本示例:两表连接(内连接 Inner Join) 假设你有两个列表:
阅读全文
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tas
阅读全文
摘要: 
阅读全文
摘要:[MemoryDiagnoser] public class DMesh3ScenarioBenchmark { private const int N = 2_000_000; // 模拟大规模几何操作 private Random rand = new Random(); [Benchmark]
阅读全文
摘要:class PointCollectSink : CallbackBase,SimplifiedGeometrySink { public class GlyphContour { public List<RawVector2> Points = new List<RawVector2>(); pu
阅读全文
摘要:static List<int> CalInts(int len=100000) { List<int> a = Enumerable.Range(0,len).ToList(); return a; } List<int> aa = CalInts(); Stopwatch sw = new St
阅读全文
摘要:一般情况,C#数组仅支持2GB大小,对于int[]来讲,大概就是:2*1024*1024*1024/4=530870912,但实际上 比这个数值略小。 int bb = 536870897; while (true) { bb++; try { int[] aa = new int[bb]; } c
阅读全文
摘要:public interface IContactManifold<TManifold> where TManifold : struct, IContactManifold<TManifold> 这个泛型约束 where TManifold : struct, IContactManifold<T
阅读全文
摘要:[StructLayout(LayoutKind.Sequential,Pack =1)]//Pack此时设为1 public struct MyStrct { public float a; public float b; public float c; public float d; byte
阅读全文
摘要:首先致谢该博文,讲解的非常详细:https://blog.csdn.net/u013339596/article/details/19167907?spm=1001.2101.3001.6650.7&utm_medium=distribute.pc_relevant.none-task-blog-2
阅读全文
摘要:ref Particle p = ref _particles[i]; 是 C# 的引用局部变量语法(ref local),它的作用是直接引用数组中某一项的内存地址,而不是创建该元素的副本。这在性能敏感或需要原地修改数组元素时非常有用。 public struct MyStrct { public
阅读全文
摘要:以下两个结构体,虽然字段完全一模一样,但因为Pack方式不同,导致它们实际占用内存大小是不一样的! [StructLayout(LayoutKind.Sequential,Pack =1)]//无填充,紧密排布 public struct TestAStrc { byte a;//1 Bit flo
阅读全文
摘要:SetPixel和GetPixel private void btnC_Click(object sender, RoutedEventArgs e) { OpenFileDialog dia = new OpenFileDialog(); dia.Filter = "图像文件|*.png;*.bm
阅读全文
摘要:var buffer = new byte[1024]; using (var ms = new MemoryStream(buffer)) { //xxx } 原因是buffer的长度过短,当接受到的字节流长度大于1024时,读不完整。 修改为: int len = 1024 * 1024 * 1
阅读全文
摘要:private static System.Text.RegularExpressions.Regex regex = new Regex("([\u0000-\uffff])"); private static System.Text.RegularExpressions.Regex cRegex
阅读全文

浙公网安备 33010602011771号