- 博客(42)
- 收藏
- 关注
原创 PLINQ
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace PLINQ_AsParallel{ public class Person { public int ID { get; set; } public stri.
2021-12-20 14:28:20
273
原创 定时器回调
在System.Threading命名空间中存在Timer类与对应的TimerCallback委托,它可以在后台线程中执行一些长期的定时操作,使主线程不受干扰。Timer类中最常用的构造函数为 public Timer( timerCallback , object , int , int )timerCallback委托可以绑定执行方法,执行方法必须返回void,它可以是无参数方法,也可以带一个object参数的方法。第二个参数是为 timerCallback 委托输入的参数对象。第三个参数是开始
2021-12-20 14:27:49
816
原创 任务并行案例
并行简单案例using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace Parallel_Test{ [Serializable] public class Person { public int ID {.
2021-12-20 14:07:00
453
原创 Linq for XML
using System;using System.Data.Linq;using System.Xml.Linq;using System.Linq; //select needusing System.Collections;namespace ConsoleApplication1{ class Program { static void Main() { #region linq_1 //.
2021-12-14 12:22:37
392
原创 SOAP for WebService
GetToolInfor.xml<?xml version="1.0" encoding="utf-8" ?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body
2021-12-14 12:02:32
357
原创 Windows启动时自动运行程序
打开启动文件夹 仅对当前用户生效:C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup 对所有用户生效:C:\ProgramData\Microsoft\Windows\Start Menu\Program\Startup 新建运行程序的bat程序的xxx.txt文件,写入启动程序后,将文件名改为xxx.bat,start /d "C:\Program Files\TightVNC" t
2021-12-13 16:19:24
389
原创 带List的类的序列化实例
Product类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Xml;using System.Xml.Serialization;namespace XmlSerialization{ //[XmlRoot(ElementName = "Product")] public class
2021-12-13 15:40:48
425
原创 C# WPF for TaskDialog
添加引用 using System.Runtime.InteropServices;导入dll [DllImport("comctl32.dll", PreserveSig = false, CharSet = CharSet.Unicode)] static extern TaskDialogResult TaskDialog(IntPtr hwndParent, IntPtr hInstance, string title, ...
2021-11-03 15:10:50
307
原创 C++ 字符与数的转换
CString转换成intint_16 = (int) wcstol(str_value,NULL,16);int_10 = (int) wcstol(str_value,NULL,10);int_8 = (int) wcstol(str_value,NULL,8);CString转换成floatfloat f=atof(str);char 转换成CString转成16进制字符串strValue.Formate(_T("%2x"),ch[i]);转成10进制字符串str.
2021-10-28 16:55:46
138
原创 MFC 生成DLL给应用程序使用
在dll项目中,定义class时添加AFX_EXT_CLASSclass AFX_EXT_CLASS className{}在项目属性里添加_AFXDLL和_AFXEXT两个宏Runtime LIbrary 选择MDlinker–>input->additional dependencies添加dll项目lib文件名linker->general->Additional Libraray Directories添加lib文件夹所在路径...
2021-10-28 15:52:28
179
原创 WPF如何使用log4net
一 安装配置log4net1. 下载log4net选择生成的项目,右键,再选择‘Manage NuGet Packages’2. 搜索log4net,并安装1. 选择生成的项目,右键添加‘App.config’4. 写配置文件在上一步生成的App.config中写log4net的配置文件<configurattion> <configSections> <section name="log4net" type="log4net.Config.Log4Ne
2021-09-07 15:25:47
4817
1
原创 如何在自建线程设置中Brush
用静态Brushes值定义Brush brush = Brushes.LightBlue; //Brushes内的值为静态值,可以跨线程使用用SolidColorBrush定义,调用 Freeze() 方法,调用之后,其 Dispatcher 属性会被设为 null,于是对象brush可以跨线程访问。Brush brush = (Brush)brushConverter.ConvertFromString("#FF0CF058");brush.Freeze();...
2021-07-06 11:19:17
134
原创 DatagridToExcel
WPF datagrid转换成Excelusing System;using System.collections.Generic;using System.Reflection;using Excel=Microsoft.Office.interop.Excel;using System.Data;using System.Windows;namespace XXXXXX{ public calss EcportTo Excel { public DataTable DataToP
2021-04-20 15:43:51
299
原创 WPF DataGrid
datagrid 添加双击事件<DataGrid> <DataGrid.Resources> <Style TargetType="DataGridRow"> <EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/> <Style TargetType="DataGridRow"> </DataGrid.Resource></Data
2021-04-16 11:29:35
230
原创 XML结构简介
XML结构简介NodeType:XmlDeclaration eg. <?xml version="1.0"?>WhitespaceComment eg. Element eg. '<'ElementName ArAttribute1 =“1” Attribute2=“2” ‘>’Text eg. ‘<‘Element’>‘Text’<’/Element’>’EndElement eg. ‘<’/ElementName
2021-03-18 15:42:34
233
原创 socket通讯
同步通讯Socket remoteSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);remoteSocket.SendTimeout = 2000;remoteSocket.ReceiveTimeout = 2000;
2021-03-09 13:59:19
124
原创 C# IPC pipe管道通讯
PipeServerusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.IO.Pipes;using System.Threadin
2021-01-06 16:39:35
448
原创 LINQ (语言集查询)
实现了IEnumerable接口的类型的实例可以用where数组,list等都可以使用LINQ示例/******筛选*******/var racers = form r in Formulal.GetChampions() where r.Wins>15 && (r.Country == "Brazil"||r.Country == "Austria") select r;foreach(var r in racers){ console.WriteL
2020-12-22 14:54:28
109
原创 string,stringBuilder,Regex(正则表达式)
string类功能非常强大方法作用Compareright-aligned 比较字符串Concat把多个字符串实例合并为一个·Copy To把特定数量的字符从选定的下标复制到数组的一个全新实例中Format格式化IndexOf定位字符第一次出现的位置IndexOfAnyInsertJoinLastIndexOfLastIndexOfAnyPadLeftReplease替换字符或字符串Spli
2020-12-21 15:23:19
369
原创 事件
事件需要委托实现,事件的流程如下:发布器类订阅器类触发实例化发布器实例化订阅器注册触发(注销)示例/*发布器*/public class EventTest{ private int value; public delegate void NumManipulationHandler(); pubic event NumManipulationHandler ChangeNum; protected virtual void OnNumChanged() {
2020-12-21 11:26:54
132
1
原创 多播委托
void Action < T t > 可以实现多播委托static void Main(string[] args){ Action<double> operations = MathOperations.MultiplyByTwo;//委托方法1 operations += MathOperations.Square;//委托方法2(多播) ProcessAndDisplayNumber(operations,2.0); ProcessAndDisplayNumber
2020-12-18 12:07:54
107
原创 运算符小结
条件运算符condition ? true_value:false_valueint x = 1;string s=x+" ";s+=(x==1? "man":"men");Console.WritheLine(s);checked 和 unchecked运算符checked 溢出检查,抛出OverflowExceptionunchecked 禁止溢出检查byte x =255;unchecked //or checked{ x++;}Console.WriteLine(x.
2020-12-18 10:55:29
99
原创 数组,枚举,元组,字典
一维数组int[] myArray;//声明myArray = new int[4];//初始化int[] myArray = new int[4];//声明+初始化int[] myArray = new int[4]{4,8,9,9};int[] myArray ={4,8,9,6};自定义类型的数组public class Person//定义person类{ public string FirstName{get;set;} public string LastName{get;
2020-12-17 16:17:04
227
原创 C#多线程之委托
1 委托(Delegate)+ 调用(Invoke)public delegate int TakesAWhileDelegate(int data, int ms);//定义委托int TakesAWhile(int data, int ms)//委托实例{ }void Mian(){ TakesAWhileDelegate d1 = TakesAWhile; IAsynResult as = d1.BeginInvoke(1,3000,null,null)//异步调用 while(
2020-12-17 09:32:38
1415
原创 TortoiseGit 局域网版本库的创建方法
TortoiseGit 局域网版本库的使用方法1 制作映射驱动器,映射远程文件夹2 在本地文件夹,创建版本库i 在本地文件夹,鼠标右键选择“在这里创建版本库”2 在映射盘内,制作制作纯版本库i 在映射文件夹,鼠标右键选择“克隆”ii URL选择本地文件,勾选克隆成村版本3 在本地文件加将需要版本管理的文件添加,并提交后,就可以正常“拉去和推送”了4 克隆失败,从新操作前需要在本地文件夹内删除隐藏文件夹“.git”...
2020-12-09 10:04:45
1311
原创 C++ 程序获取编译时间
C++ 14以前可以通过一下程序void GetCurPath(TCHAR* exeFullPath) { memset(exeFullPath,0,MAX_PATH); GetModuleFileName(NULL,exeFullPath,MAX_PATH); } CString GetExeTime() { TCHAR exeFullPath[MAX_PATH]; GetCurPath(exeFullPath); WIN32_FIND_DAT
2020-10-15 15:51:00
1159
原创 C#时间日期处理及版本处理
1 DateTime 日期格式语法示例(2016-05-09 13:09:55:2350)格式说明DateTime.Now.ToString(““yyyy-MM-dd HH:mm:ss.ff””)2016-05-09 13:09:55.45自定义格式DateTime.Now.ToString()2016/5/9 13:09:55短日期 长时间DateTime.Now.ToString(“d”)2016/5/9短日期DateTime.Now.ToStrin
2020-10-15 11:44:06
251
原创 excel 中英文 显示星期,月份
excel 显示星期假设 A1 = 2020年10月12日英文显示text(A1,"[$-en-cn]dddd") 显示Monday 英文显示text(A1,"[$-en-cn]ddd") 显示Mon 中文显示text(A1,"[$-zh-cn]dddd") 显示星期一中文显示text(A1,"[$-zh-HK]ddd") 显示 週一//繁体中文显示text(A1,"[$-zh-cn]ddd") 显示 周一//简体excel显示月份假设 A1 = 2020年10月12日英文显示text(
2020-10-13 16:37:51
2880
原创 批处理文件
.bat 用法1 echo 显示或隐藏批处理程序中的正文echo off echo. echo This batch program echo formats and checks echo new disks echo. 2. net use 网络连接net use //列出网络连接 net use username /delete //取消指定网络连接。如果用户以星号指定连接,则取消所有网络连接。 net use /d d: //删除网络连接 d:net use d: \
2020-10-08 14:08:26
1395
原创 如何使程序在Debug状态或是Release状态下运行不同的代码(Under VS2010)
1. 属性里定义宏Debug Definitions 里定义_DEBUGRelease Definitions 里不要有_DEBUG2. 程序里判断是否定义了宏#if _DEBUG //必须与定义的一样#else#endif
2020-09-23 16:50:41
240
原创 C++ 强制关闭进程 Force Terminate Process
强制关闭进程方法执行Windows CMD指令:system(""); system("taskkill /f /t /im appName.exe");使用TerminateProcess()结束进程(推荐使用)HANDLE hself = GetCurrentProcess(); TerminateProcess(hself, 0);
2020-09-10 17:09:33
4475
2
原创 CString与LPCWSTR、LPSTR、char*、LPWSTR等类型的转换【转】
CString与PLCWSTR,PLSTR,CHAR 存放单个字符WCHAR 存放双字符TCHAR 与WCHAR无异PTCHAR 指向双字符类型字符串LPSTR 一个32位的指向字符串的指针LPCSTR 一个32位的指向字符串常量的指针LPWSTR 一个32位的指向unicode字符串的指针LPCWSTR 一个32位的指向unicode字符串常量的指针PSTR 指向字符串的指针,poionter string注:很多变量前加lpsz,l
2020-08-28 14:43:08
2025
转载 MFC获取文件版本信息
.h头文件CString GetProductVersion(LPCTSTR lpszFileName = NULL)cpp文件头部加入version.lib#pragma comment(lib, "Version.lib ") 功能代码/*=================================================================功能:获取文件版本信息. 说明:要使用此函数必需在程序中加入 ----------------
2020-08-28 11:40:11
931
原创 C#自动引用Debug | Release版本的dll
自动引用Debug | Release版本的dll的方法创建$(Configuration)文件夹,并复制dll文件到该文件夹(任意版本的dll都可以)文本格式打开.csproj工程文件,按下面方法修改修改前:<ItemGroup> <Reference Include="ClassLibrary1,Version=1.0.0.0,Culture=neutral,processorArchitecture=MSIL"> <Spec
2020-06-23 14:48:27
1246
原创 Lambda函数
Lambda表达式简介简单举例用lambda表达式简化委托简介符号 =>,读作 goes to作用 直接使用=>查询,代替foreach或for循环Lambda表达式是一种匿名函数,Lambda 用在基于方法的 LINQ 查询中,作为诸如 Where 和 Where 等标准查询运算符方法的参数简单举例返回classcode为1001的list 或1001号学生 List<Student> list1001=StudentList.where (t=>t
2020-06-09 10:58:24
249
原创 c#类型转化 is,as(尽量使用as,少用类型强制转换)
is 判断变量类型是否一致class manager:person{};manager p = new manager();bool result = p is person;//result = true;as 判断后,类型一致就会转换,类型不一致返回nullclass manager:person{};manager p = new manager{};person result = p as person?;//必需有问号隐式转换int i = 10;long.
2020-06-08 17:01:55
225
原创 C# 命名空间 类 字段,属性,方法,变量, 参数
命名空间 类 字段 方法外的变量,一般为私有 属性 保护字段,set为写,get为读, value为内置隐藏变量 方法(参数) 变量 在方法内 参数在方法间传递 实际参数传递 方法(var 参数) 引用参数传递 方法(ref var 参数),调用时也要加(ref 参数),等同于参数的地址(指针) 可变参数传递 方法(params var 参数),调用时不需要再写(params) ...
2020-06-08 14:56:22
758
原创 C# for excel12.0 and more
DataSet ds = new DataSet(); string filesurffix = System.IO.Path.GetExtension(sourcePath); string strConn = ""; if (filesurffix == ".xls") strConn = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source =...
2020-06-02 09:29:04
207
1
转载 &GetListCtrl()这句话为什么函数前边有一个"&"
为什么不干脆写代码:CListCtrl ctl = GetListCtrl();或:CListCtrl ctl;ctl = GetListCtrl();无论哪一种写法,似乎更符合我们一般的逻辑思维,但执行结果都是通不过编译的。正确写法:CListCtrl* ctl = &GetListCtrl();或CListCtrl& ctl = GetListCtrl();...
2018-09-06 14:14:13
574
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人