随笔分类 - C#编程
摘要:一、Excel 1、Datagridview导出Excel https://blog.csdn.net/binbingbong/article/details/106051194 public class xlsP { public string sheetname { get; set; } pu
阅读全文
摘要:一、PDF using iTextSharp.text; using iTextSharp.text.pdf; using System; using System.Collections.Generic; using System.IO; using System.Linq; using Syst
阅读全文
摘要:需要两个dll:Ivi.Visa.dllNationalInstruments.Visa.dll 范例链接:https://pan.baidu.com/s/1_mUQ018RBIrPnqJUDaKgAQ 提取码:9sl0 private ResourceManager _rmSession; pri
阅读全文
摘要:一、内存占用大量资源的解决办法 1、定时清理 exe运行后占用内存一直增加导致软件越来越卡,调试发现是没调用一次某DLL函数就会增加一次,应该是内存泄露了,但就是没找到原因。 在主程序里加这段代码,定时清理内存,可暂时规避这一问题。 #region 内存回收 [DllImport("kernel32
阅读全文
摘要:一、无参数线程的创建 Thread thread = new Thread(new ThreadStart(getpic)); thread.Start(); private void showmessage() { Console.WriteLine("hello world"); } 二、1个参
阅读全文
摘要:一、Aspose.Cells.dll 1、从DataTable导入、导出Excel using System; using System.Collections.Generic; using System.Text; using Aspose.Cells; using System.Data; pu
阅读全文
摘要:由于弹窗语句和主窗体不在一个线程里,子线程无法影响主线程,所以会出现Messagebox弹窗后还能操作主窗体的现象。 可将弹窗语句写成: this.Invoke((MethodInvoker)delegate { MessageBox.Show("停止操作!", " fail", System.Wi
阅读全文
摘要:static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Process[] proc = Process.GetProcesses(); int cnt =
阅读全文
摘要:一、char转换成int char c = '5';int n = c - '0';//n=5 二、unsigned char与byte类型转换 byte b = 1; byte b = Convert.ToByte(1);//这两种写法一样,相当于unsigned char=1 byte b =
阅读全文
摘要:例子:https://www.cnblogs.com/masonmei/p/11527104.html 一、OpenFileDialog 1、文件多个选择openFileDialog.Multiselect=true;2、多种文件类型选择(1)多种文件类型可一起选择eg1: openFileDial
阅读全文
摘要:一、排序 char[] tmp = str.ToArray();Array.Sort(tmp); //按ASCII排序 二、字节数组转换为ASCII字符串 // 字节数组 byte[] ba = new byte[] { 119,104,97,116,50,49,46,99,111,109 }; /
阅读全文
摘要:一、用法 1、排序 //字典按键值升序排序dic = dic.OrderBy(p => p.Key).ToDictionary(p => p.Key, o => o.Value); //字典按键值降序排序 dic = dic.OrderByDescending(p => p.Key).ToDicti
阅读全文
摘要:一、ArrayList转换为数组 (1)方法1 ArrayList List = new ArrayList(); Int32[] values = (Int32[])List.ToArray(typeof(Int32)); (2)方法2 ArrayList List = new ArrayList
阅读全文
摘要:一、将List复制到另一个List 1、值类型的List List<T> newList = oldList.GetRange(index, count); 或者 List<T> newList = new List<T>(oldList); 2、引用类型的List(深度复制) 利用System.X
阅读全文
摘要:一、持续序列化对象追加到文件的方法 https://www.cnblogs.com/luxishi/p/9172407.html 二、反序列化时程序集名称不同导致错误 折腾了好久终于解决了这个问题,官方yyds https://docs.microsoft.com/zh-cn/dotnet/api/
阅读全文
摘要:/// <summary> /// 微秒级延迟,会稍有偏差 /// </summary> /// <param name="time">延迟时间 毫秒(除以1000即微秒,如输入参数0.05ms = 50us)</param> /// <returns></returns> public stati
阅读全文
摘要:一、删除文件或文件夹 File.Delete(fileName);Directory.Delete(fileName, true); /// <summary> /// 删除文件夹以及文件 /// </summary> /// <param name="directoryPath"> 文件夹路径 <
阅读全文
摘要:https://blog.csdn.net/shylx123/article/details/7415311
阅读全文
摘要:https://www.cnblogs.com/itjeff/p/8953308.html
阅读全文