- 博客(233)
- 资源 (1)
- 问答 (1)
- 收藏
- 关注
原创 go defer 4点
在Go语言中,带参数的defer语句会立即对参数求值并捕获闭包变量值,执行时才读取这些值。若需保留值变化应显式传参。循环中大量使用defer会因heap分配导致性能问题。此外,命名返回值可通过defer修改,而匿名返回值则不能。需谨慎使用这些特性以避免资源消耗和逻辑错误。
2025-06-26 11:10:50
214
原创 go vs C#/c/c++
Go,不能带参数,也不能有返回值。C/C++,参数可以直接获取命令行参数。C#,参数直接是命令行参数数组。多重继承:用组合(嵌入多个 struct)和接口实现,方法名不冲突时全部可用。虚方法/重写:用接口实现多态,用组合+同名方法实现“隐藏”。接口:Go 的接口是实现多态的核心,鸭子类型,灵活且强大。如果你有具体的 C#/C++ 复杂继承场景,想看 Go 里的实现方式,可以举例,我帮你写出 Go 代码对比!
2025-06-26 08:22:33
934
原创 为什么实现了 INotifyPropertyChanged,UI 就能自动响应数据变化?
一旦你在代码里调用 OnPropertyChanged("Name"),WPF 就会收到通知,立刻刷新所有绑定到 Name 的 UI。当你在 XAML 里写 {Binding Name} 时,WPF 会在后台建立一个“监听器”,持续关注数据对象的 Name 属性。如果这个对象实现了 INotifyPropertyChanged,WPF 会自动订阅它的 PropertyChanged 事件。// 触发 PropertyChanged,UI 自动刷新。WPF 收到事件,自动刷新绑定到该属性的 UI。
2025-06-21 10:05:48
602
原创 WPF学习PropertyChanged
让我解释一下 `PropertyChanged` 事件的订阅过程。在 WPF 中,当我们使用数据绑定时,WPF 框架会自动订阅 `PropertyChanged` 事件。WPF 框架会处理剩下的所有事情,包括事件订阅和 UI 更新。3. 当我们调用 `OnPropertyChanged` 时,所有订阅的 UI 元素都会收到通知并更新。2. 这个对象会自动订阅目标对象(ViewModel)的 `PropertyChanged` 事件。3. 在属性变化时调用 `OnPropertyChanged`
2025-06-07 10:35:25
621
转载 lock history and explaination:https://mareks-082.medium.com/new-lock-object-and-history-d69877f46521
Lock keyword gets an upgrade in .NET9 | by Marek Sirkovský | Medium
2025-01-23 10:06:22
40
原创 汤姆森采样 https://www.sohu.com/a/467995982_121123911
什么是汤普森采样(Thompsonsampling)?_算法
2025-01-20 11:14:40
158
原创 typescript for C# developer
TypeScript: Documentation - TypeScript for Java/C# Programmers
2024-12-20 16:17:41
156
原创 what difference between make(chan int, 1) and make(chan int) in golang?
【代码】what difference between make(chan int, 1) and make(chan int) in golang?
2023-11-04 11:27:56
306
原创 in golang, how many usages are there for pointer? and can you provide example for each of them?
``go*ptr = 42value := 0``````go// fields``````gocount intc.count++``````gonum := 42```
2023-09-07 09:58:20
129
原创 ACID的解释
I有read uncommitted, read committed, repeatable read (开启事物后,锁住第一次查询的数据行,不许读写更新操作。但是管不住插入行), serialization(加了范围锁,阻止整个范围其他事物再读写更新)
2023-08-22 10:21:06
91
原创 儿童启蒙英语
What's the Big Idea (画质不好) (画质不好) 腾讯 (高清) (高清))Charlie and Lora (不清晰) (不清晰)
2023-06-30 15:15:48
269
原创 Java的private, default, protected public的变量访问范围
对于这四个变量,private和public都很好记住。对于default和protected,总结如下:可以看到下面红色的字段是不能访问的。所以网上的我加了红色的部分
2023-05-03 10:50:57
161
1
原创 CSV file转成各个字段都加双引号
$path = "C:\tmp\112.csv"$data = Import-Csv -Path $Path$ColNames = ($data[0].psobject.Properties).name$header = ""foreach($column in $ColNames){ if(![string]::IsNullOrEmpty($header)){ $header = $header + "," $header = $header + $column
2022-06-01 17:18:47
1413
原创 快速排序C#代码
using System;namespace ConsoleApp12{ class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); int[] aa = new int[] {3,12,8,7,4,3,89,1 }; QuickSort(aa, 0, aa.Length .
2022-01-18 10:13:37
480
原创 leetcode :https://leetcode.com/problems/container-with-most-water/
public static int MaxArea(int[] b) { if (b.Length <= 1) { return 0; } int max = 0; int l = 0; int r = b.Length-1; while (l < r) .
2022-01-07 09:48:49
190
原创 求字符串中最长的回文字符串
using System;namespace ConsoleApp11{ class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); GetHuiWen2("cbbd"); } public static int GetHuiwen(string s, int l.
2021-12-30 09:50:54
277
原创 Add two numbers for leetcode
Loading...no more words, see codes:using System;namespace ConsoleApp10{ class Program { public class Node { public int data; public Node next; } //approach1: recursive public
2021-12-22 10:00:03
156
原创 Redis: requirepass and masterauth
version 6.2.1when I only set requirepass in redis.conf, and create redis cluster, the following error is raised in log:Unexpected reply to PSYNC from master: -NOAUTH Authentication required.so I add requirepass and masterauth in redis.conf. no erro.
2021-09-27 11:05:50
1466
原创 在构造函数还没有被执行的情况下,它的其他函数被执行了。
public class Class2 : IClass1 { public string cc = null; public Class2() : base("redis") { sssss = "1111"; cc = "cc"; } public override void SetConfig() { test();...
2021-09-01 09:47:25
238
原创 ReaderWriterLockSlim vs ReaderWriterLock
看MS official doc, we can know the performance Slim is better than ReadWriteLock.但是ReaderWriterLockSlim的使用场景也有限制比如这个TryEnterUpgradableReadMode, 这个Upgradable mode, 只能一个线程 in this mode,有点鸡肋(当然也有他的使用场景,比如只有一个线程可能写,其他线程只有读,可能好用)。...
2021-08-18 17:17:45
504
原创 ReaderWriterLock当获取Writelock时,是等到其他的ReaderLock都释放了,才能拿到WriteLock.
看代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;using System.Reflection;using System.Threading;namespace ConsoleApplication23{ class Program { p
2021-08-18 17:09:07
187
原创 Kubernet ConfigMap读书笔记
1. 使用configmap的限制条件 a. ConfigMap必须在pod之前创建 b. ConfigMap也可以定义为属于某个Namespace.只有处于相同namespace中的Pod可以饮用它 c. ConfigMap中的配置管理还未能实现 d. kubelet...
2021-08-04 20:23:37
104
原创 泛型和多态的比较
比如T test<T>(T info){return T;}public class interface IInfo{}IInfo test(IInfo info) {return info;}对于这两个方法,下面接口的运行效率更高,因为泛型其实是会多生成若干份相似的代码。
2021-06-30 09:36:21
232
转载 aysnc await deadlock for UI applicaiton and asp.net application.
https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html
2021-05-08 10:01:42
105
原创 Git: checkin后,看到有文件只有The file only whitespace difference,如何解决如下,回退版本
The file only whitespace issue: 仍然显示Git checkout commitid fileNote: the commitid is git log的上一个版本commitid,不是特定文件的上一个版本Git addGit commitGit push 即可解决
2021-04-20 09:41:49
332
原创 serialize是想改变保存到文件中的assemblyName,可以在这里修改
保存类型如下:<Student z:Id="1" z:Type="ClassLibrary1.Student" z:Assembly="ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8879e74bfbe2761e" xmlns="http://schemas.datacontract.org/2004/07/ClassLibrary1" xmlns:i="http://www.w3.org/2001/XMLSche
2021-03-31 19:50:45
205
原创 Debugging custom rule codes with VS and FxCop UI
While writing your custom rule,you will likely come across a need to debug it and work out why it's behaving in a particular manner.Debugging within FxCopDebugging a custom rule within the FxCop UI is actually quite easy. To do so, simply:Open the Fx..
2021-02-28 12:53:33
122
原创 asp.net core lifetime transient, scoped, singleton.
如下是我在stackoverflow拷贝的一句话,觉得正确。最难理解的就是这个Scope:,我们大部分情况下,一个Scoped就是一个http request请求。其实上Scope就是Scopecontainer.CreateScope().ServiceProvider.GetService<ITestService>();这里就是新建立一个Scope了。这app.net core console里可以这样用。在asp.net core mvc里,每个request会默认创建了一个
2021-02-21 12:12:23
346
原创 ASP.net Core IApplicationBuilder Run and Use的区别
要配置多个中间件,请使用Use()扩展方法。与Run()方法类似,不同之处在于它包括用于调用序列中的下一个中间件的下一个参数publicvoidConfigure(IApplicationBuilderapp,IHostingEnvironmentenv){app.Use(async(context,next)=>{awaitcontext.Response.WriteAsync("1stMW!");awaitnext();})...
2021-02-21 10:53:47
1255
原创 asp.net core kestrel
kestrel只能作为单一的web server, 这样的话,若是在生产环境,同一个role需要多个进程,这是在kestrel前面就要加个反向代理的功能(这个可以用nignx或者iis来做),然后在发给后面的kestrel处理。
2021-02-19 19:05:09
303
1
原创 asp.net core mvc源代码本地调试
1. 在tools下的option下,找到debug->symbols下,把"Microsoft Symbol servers" and "Nuget.org symbol servers" 都勾选了;2. 在Debug下的general下,uncheck the "Enable just my codes";3. 然后跑起一个mvc 项目,期间它会自动下载symbol (可能会下载很慢,若没有美国代理)...
2021-02-09 13:07:52
503
转载 asp.net mvc request life cycle
http://geekswithblogs.net/chetan/archive/2015/06/30/a-detailed-walkthrough-of-asp.net-mvc-request-life-cycle.aspx
2021-02-02 16:38:02
138
转载 转载:io多路复用https://www.jianshu.com/p/7fbda1696789
https://www.jianshu.com/p/7fbda1696789
2021-01-11 08:13:24
509
转载 声明式编程与命令式编程
声明式编程和命令式编程https://blog.csdn.net/weixin_30443813/article/details/95675962?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLe
2020-12-15 10:11:37
126
转载 Apache一个协议的解释,一张图搞定
http://www.ruanyifeng.com/blog/2011/05/how_to_choose_free_software_licenses.html
2020-12-11 11:44:15
208
1
转载 微软在用的一个开源项目.netcore
https://github.com/geffzhang/NanoFabric
2020-10-27 18:01:42
286
TA创建的收藏夹 TA关注的收藏夹
TA关注的人