随笔分类 - C#
摘要:窗体中拖入 notifyIcon 组件notifyIcon 中的 ICON 属性 显示的图标下面是系统托盘的基本功能代码(单击最小化窗体隐藏,双击图标显示)及窗体关闭时退出确认代码。 //单击最小化窗体隐藏 private void frmMain_SizeChanged(object sender, EventArgs e) { if (this.WindowState == FormWin...
阅读全文
摘要:using System.Runtime.InteropServices;[DllImport("kernel32.dll")] public static extern bool Beep(int freq,int duration); public void PlayBeep(){//调用Beep(800,3000); }
阅读全文
摘要:一、时间间隔 /// summary时间间隔/summary /// param name="DateTime1"第一个日期和时间/param /// param name="DateTime2"第二个日期和时间/param /// returns同一天的相隔的分钟的整数部分/returns private int DateDiff(DateTime DateTime1, DateTime DateTime2) { TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); TimeSpan ts2 = new TimeSpan(
阅读全文
摘要:using System.IO;DirectoryInfo di = new DirectoryInfo(strXmlFilePath);FileInfo[] f = di.GetFiles("*.xml");//获取指定扩展名的文件//没有xml文件if (f.Length <= 0){return;}//遍历所有文件(*.xml)foreach (FileInfo myFile in f...
阅读全文
摘要:在写代码时经常遇到字符串截取问题,下面是在C#编程中一种不错的截取方式。string str="A,B,C,D";string strTemp1=str.Split(new char[] { ',' })[0];string strTemp2=str.Split(new char[] { ',' })[2];则结果为 strTemp1 为 AstrTemp2 为 C
阅读全文
摘要:Microsoft SQL serverwindows安全登陆 "Data Source=(local); Initial Catalog=Northwind; Integrated Security=True;"SQL Server登陆"Data Source=(local); Initial Catalog=Northwind; UserID=sa; PassWord=111111;"Acce...
阅读全文
摘要:C#中委托与事件的基本使用方法://定义委托模板Public delegate void ReceiveMsgEventHandled(object sender,clsTcpMsgEventArgs e);//定义事件private event ReceiveMsgEventHandler ReceiveMsgEvent;//公有事件,注册事件Public event ReceiveMsgEve...
阅读全文
摘要:一、条件语句:if(条件){ //执行语句 }else if{条件}{ //执行语句 }else{ //执行语句 }int i=0;swith(i){ case 0: //执行语句 break; case 1: //执行语句 break; default: //都不满足则执行此语句 break;}二、循环语句:for(int i=0;i<10;i++...
阅读全文
摘要:有两种方式:.net wsdl文件用法(一)工程—引用Web服务 添写wsdl文件地址,单击前往,修改命名空间,确定。 命名空间.WebService名称.FileServiceClient fs = new 命名空间.WebService名称.FileServiceClient();//实例化webservice客户端对象(二)通过WSDL文件自动生成类-WebService ...
阅读全文
摘要:用MySQLDriverCS连接MySQL数据库 先下载和安装MySQLDriverCS,地址: http://sourceforge.net/projects/mysqldrivercs/ 在安装文件夹下面找到MySQLDriver.dll,然后将MySQLDriver.dll添加引用到项目中 注:我下载的是版本是 MySQLDriverCS-n-EasyQueryTools-4.0.1-Dot...
阅读全文
摘要://读Xml至DataTable private void butInputXml_Click(object sender, EventArgs e) { DataSet ds = new System.Data.DataSet(); ds.ReadXml(this.txtXmlFile.Text); DataTable dt = ds.Tables[0]; this.dataGridVie...
阅读全文
摘要:using System;using System.Text;using System.Net.Sockets;using System.Net;namespace myClass{ class clsListenPort { #region 使用说明 /* 用途:监听某IP,指定端口,捕获通过此端口的消息。 举例: private delegate void ListenPostModel(st...
阅读全文
摘要:C# 控件的缩写1 btn Button 2 chk CheckBox 3 ckl CheckedListBox 4 cmb ComboBox 5 dtp DateTimePicker 6 lbl Label 7 llb LinkLabel 8 lst ListBox 9 lvw ListView 10 mtx MaskedTextBox 11 cdr MonthCalendar 12 icn N...
阅读全文