随笔分类 - .NET
摘要://.net 4.0 设置: ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //.net 4.5 设置: ServicePointManager.SecurityProtocol = SecurityProtoc
阅读全文
摘要:public static void ExportExcelFile(DevExpress.Xpf.Grid.TableView tableView) { if (tableView == null) { MessageBox.Show("导出失败!", "错误提示", MessageBoxButt
阅读全文
摘要:1、foreach遍历列表或数组时,如果list或数组为null,就会报错,如下图: 2、不知道微软封装foreach的为什么不先检查要遍历的对象是否为null,这样就导致,我们在写代码时,遍历列表时就要先判断列表是否为null,如下图: 3、为了简化这一判断是否null的过程,我写了一个扩展方法,
阅读全文
摘要:protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); FontFamily fontFamily = new FontFamily("Times New Roman"); Font font = new Font(
阅读全文
摘要:bitPhoto.Save(Response.OutputStream, ImageFormat.Jpeg); 图像保存的问题,默认的质量是60% EncoderParameter p; EncoderParameters ps; ps = new EncoderParameters(1); p =
阅读全文
摘要:Introduction# When WPF application launched, it could take a while for a current language runtime (CLR) to initialize .NET Framework. As a result, fir
阅读全文
摘要:简单的岁数计算 DateTime now = DateTime.Today; int age = now.Year - bday.Year; if (bday > now.AddYears(-age)) age--; /// <summary> /// 计算日期的间隔(静态类) /// </summ
阅读全文
摘要:概况 启动不带参数线程的方法 启动带参数线程的方法 线程更新UI 线程锁同步共享数据 启动不带参数线程的方法 第一种快速启动 1 2 3 4 Thread t = new Thread(()=>{ //下面写一些在线程中处理的方法 }); t.Start(); 第二种启动方法 1 2 3 4 5 6
阅读全文
摘要:using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using abc = Iner; namespace Test { class Program
阅读全文
摘要:线程与异步的使用方法 使用场景 方法 AAA, BBB, CCC 在主线程不阻塞的情况下运行不同的三个方法 方法CCC需要在方法AAA完成后执行 使用线程完成 因为方法 CCC 要等待方法 AAA 完成,所以需要一个线程同步事件。 using System; using System.Threadi
阅读全文