随笔分类 - C#
摘要:1、项目用到依赖注入参考: https://www.cnblogs.com/handsomeziff/p/16390502.html 2、新建ICaching接口 using Microsoft.Extensions.Caching.Distributed; namespace YYApi.Cach
阅读全文
摘要:dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSiz
阅读全文
摘要:java: /** * sha1加密 * * @param encryptText 加密文本 * @param encryptKey 加密键 * @return 加密 */ private static String hmacSHA1Encrypt(String encryptText, Strin
阅读全文
摘要:java中的System.currentTimeMillis()返回从1970年1月1日开始的以毫秒为单位的当前时间 public static long DateTimeToTimestamp() { DateTime Jan1970 = new DateTime(1970, 1, 1, 0, 0
阅读全文
摘要:1、打开PowerShell,输入以下命令,该命令会创建一个证书,并颁发给localhost New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname localhost -NotAfter 2060-01
阅读全文
摘要:/// <summary> /// INI文件读写类。 /// </summary> public class INIFile { public string path; public INIFile(string INIPath) { path = INIPath; } [DllImport("k
阅读全文
摘要:#region 向当前活动文本框输入文字 /// <summary> /// 向当前活动文本框输入文字 /// new SendMsg().SendText("你要输入的字符串"); /// </summary> public class SendMsg { [DllImport("user32.d
阅读全文
摘要:access 查询报“提供程序无法确定 Object 值.例如,该行刚刚创建,未提供 Object 列的默认值,并且” System.InvalidOperationException: The provider could not determine the Object value. For e
阅读全文
摘要://引入命名空间:using System.Runtime.InteropServices; [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)] private static extern bool Set
阅读全文
摘要:启动程序: string path="d:\\test.exe"; //外部winform程序 string args = "aa bb cc"; System.Diagnostics.Process.Start(path,args); //启动程序 外部winform程序test.exe接收参数:
阅读全文
摘要:System.InvalidOperationException: 集合已修改;可能无法执行枚举操作。 在 System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) 在 System.Collectio
阅读全文
摘要:CefSharp打开不安全的https站点时白屏解决办法: CefSettings settings = new CefSettings(); settings.CefCommandLineArgs.Add("--ignore-urlfetcher-cert-requests", "1");//证书
阅读全文
摘要:问题原因 使用CefSharp控件,在部分高分辨率的电脑中(显示缩放比例非100%,而是120%或者125%等)会出现以下一些情况: 显示的页面中出现了黑边,且按钮定位也偏了,比如点击【图层】按钮,需要点击上面黑色边框中的相对位置。 解决方法1: var settings = new CefSett
阅读全文
摘要:winform弹出来窗口,自定义弹出位置试了this.Top和this.Location,均无效。查资料需要先设置窗体的定位方式才能生效FormStartPosition.Manual win.StartPosition = FormStartPosition.Manual;
阅读全文
摘要:一、说明 Task.WhenAll()、Task.WhenAny()这两个与Task.WaitALL()、Task.WaitAny()是有区别的,When是异步的,Wait是同步的。Task.WhenAll():所有task完成时,task才完成,用于等待多个任务执行结束。Task.WhenAny(
阅读全文
摘要:.NET 提供了一个类方便用来发出操作取消的信号,这个类就是CancellationToken,它的好处在于它可以在任意数量的线程之间、线程池任务之间、Task之间传递信号,并且所需的代码很简单。通常用于下载超时中断、用户取消任务等情况。 CancellationToken 通常搭配 Cancell
阅读全文
摘要:一、要在异步方法中需要延迟代码继续往下执行可以使用await Task.Delay(),效果类似Thread.Sleep()。 两者之间的不同是 1、await Task.Delay实质创建一个运行给定时间的任务,不会引起程序卡死。Thread.Sleep使当前线程休眠给定时间,会引起来程序卡死。
阅读全文
摘要:1、先将取出来的16进制卡号颠倒如F3 0C 4F 06转成06 4F 0C F3 (注意物理卡号是第0扇区的前4个字节) 2、将转换后的16进制卡号转成10进制,不足10位左补0 代码实现: //调用: GetM1CardNo("F30C4F06"); 1 private string GetM1
阅读全文
摘要:CefSettings settings = new CefSettings(); CefSharpSettings.WcfEnabled = true; settings.CefCommandLineArgs.Add("autoplay-policy", "no-user-gesture-requ
阅读全文
摘要:net core6 webapi接口返回JSON字段首字母自动转成小写,可以在Program.cs里面加 builder.Services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.Prope
阅读全文