随笔分类 -  C#

一些基于C#语言的技术实例
摘要:C# 集合 using System.Data; using System.Collections; //数组(Array) string[] arr = { "Hello", "World" }; int[] nums = { 1, 99, 2, 66, 15, 8 }; //哈希表(Hashta 阅读全文
posted @ 2022-11-26 18:50 microsoft-zhcn 阅读(90) 评论(0) 推荐(0)
摘要:[System.Runtime.InteropServices.DllImport("wininet")] private extern static bool InternetGetConnectedState(out int connectionDescription, int reserved 阅读全文
posted @ 2022-11-12 17:51 microsoft-zhcn 阅读(122) 评论(0) 推荐(0)
摘要:MainWindow.xaml <Window x:Class="SevenZipTestWPF.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas 阅读全文
posted @ 2022-11-12 17:43 microsoft-zhcn 阅读(281) 评论(0) 推荐(0)
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; //使用DllImport需导入命名空间 using System. 阅读全文
posted @ 2022-11-12 16:14 microsoft-zhcn 阅读(295) 评论(0) 推荐(0)
摘要:Linq提供两种方法:方法语法(Lambda语法)、查询语法(Linq语法) https://blog.csdn.net/weixin_45756851/article/details/126163607https://www.nhooo.com/note/qa074s.htmlhttps://bl 阅读全文
posted @ 2022-11-01 11:05 microsoft-zhcn 阅读(171) 评论(0) 推荐(0)
摘要:创建型模式: 单例(Singleton)模式:某个类只能生成一个实例,该类提供了一个全局访问点供外部获取该实例,其拓展是有限多例模式。 原型(Prototype)模式:将一个对象作为原型,通过对其进行复制而克隆出多个和原型类似的新实例。 工厂方法(Factory Method)模式:定义一个用于创建 阅读全文
posted @ 2022-11-01 10:34 microsoft-zhcn 阅读(5303) 评论(0) 推荐(0)
摘要:约束说明 T : 结构 T必须是值类型。可以指定除 Nullable 以外的任何值类型。 T : 类 T必须是引用类型,包括任何类、接口、委托或数组类型。 T : 接口名称 T必须继承该接口,并实现其中的所有方法。可以指定多个接口约束。 T : 类名称 T必须该类本身或者继承其的基类类。 T : n 阅读全文
posted @ 2022-10-29 17:41 microsoft-zhcn 阅读(102) 评论(0) 推荐(0)
摘要:一、依赖注入定义: 只依赖于服务类的一个接口,而不依赖于具体服务类。 二,依赖注入的类别1.构造注入 2.Setter注入 示例: using System; using System.Collections.Generic; using System.Linq; namespace SetterI 阅读全文
posted @ 2022-10-29 17:12 microsoft-zhcn 阅读(314) 评论(0) 推荐(0)
摘要:C# JsonConvert时间格式问题 var format = new IsoDateTimeConverter(); format.DateTimeFormat = "yyyy-MM-dd hh:mm:ss"; string param = JsonConvert.SerializeObjec 阅读全文
posted @ 2022-04-19 12:05 microsoft-zhcn 阅读(49) 评论(0) 推荐(0)
摘要:XLS默认组件为2003: XLSX下载组件:AccessDatabaseEngine2007 下载地址:https://dl.pconline.com.cn/download/1059627.html DataTable dt = new DataTable(); string con = "Pr 阅读全文
posted @ 2022-03-24 17:08 microsoft-zhcn 阅读(250) 评论(0) 推荐(0)
摘要:第一步:进入 https://www.nuget.org 注册账号 第二步:进入 https://www.nuget.org/downloads 下载nuget.exe 配置环境变量 第三步:创建项目获取密钥 第四步:配置全局Push源地址 nuget config -Set DefaultPush 阅读全文
posted @ 2021-10-21 18:14 microsoft-zhcn 阅读(310) 评论(0) 推荐(0)
摘要:Redis是什么? Redis是一个开源的、使用C语言编写的、支持网络交互的、可基于内存也可持久化的Key-Value数据库。 第一步:下载Redis,并安装 下载连接:https://github.com/microsoftarchive/redis/releases 安装之后,出现Redis服务 阅读全文
posted @ 2021-10-19 10:32 microsoft-zhcn 阅读(67) 评论(0) 推荐(0)
摘要:转换为UTF8编码 public static string UTF16To8(string str) { byte[] utf16Bytes = Encoding.Unicode.GetBytes(str); byte[] utf8Bytes = Encoding.Convert(Encoding 阅读全文
posted @ 2021-10-11 10:17 microsoft-zhcn 阅读(47) 评论(0) 推荐(0)
摘要:异步和同步主要用于修饰方法,调用者需要等待方法执行完并返回后才能继续执行就称为同步方法,调用者不用等待该方法执行完毕,称为异步方法。 阅读全文
posted @ 2021-09-27 12:06 microsoft-zhcn 阅读(175) 评论(0) 推荐(0)
摘要:实例:按钮异步事件,非UI堵塞 // 按钮事件,异步事件,获取结果,非UI堵塞 private async void WindowTask_Click(object sender, EventArgs e) { string getstr = await Task.Run<string>(() => 阅读全文
posted @ 2021-09-24 18:36 microsoft-zhcn 阅读(621) 评论(0) 推荐(0)
摘要:1、颜色渐变(从上而下) <Path Height="64" Stretch="Fill" Data="*"> <Path.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#1c 阅读全文
posted @ 2021-09-17 12:39 microsoft-zhcn 阅读(763) 评论(0) 推荐(0)
摘要:解决方案:Dispatcher.Invoke(new Action(delegate{ })); 阅读全文
posted @ 2021-09-13 18:28 microsoft-zhcn 阅读(69) 评论(0) 推荐(0)
摘要:1、ThreadPool不支持线程的取消、完成、失败通知等交互性操作2、ThreadPool不支持线程执行的先后次序 //通过匿名委托创建 Thread thread1 = new Thread(delegate () { Console.WriteLine("我是通过匿名委托创建的线程"); }) 阅读全文
posted @ 2021-09-13 18:07 microsoft-zhcn 阅读(43) 评论(0) 推荐(0)
摘要:EF批量,参数: https://www.cnblogs.com/shanshanlaichi/p/6666074.html https://www.cnblogs.com/seanchang/p/9187619.html #region 16-批量删除 /// <summary> /// 16-批 阅读全文
posted @ 2021-09-10 18:10 microsoft-zhcn 阅读(563) 评论(0) 推荐(0)
摘要:C# win7 win10 系统音量控制 参考:https://blog.csdn.net/yuhijk2055/article/details/81870529 阅读全文
posted @ 2021-08-31 23:44 microsoft-zhcn 阅读(113) 评论(0) 推荐(0)