摘要:DataGridView扩展方法行号、全选、导出到Excel(引用excel组件、生成html两种方式)
阅读全文
随笔分类 - C#
摘要:以下配置了二种写文件,第一种根据日期写文件yyyyMMdd.txt,第二种是写固定文件login.txt。
阅读全文
摘要:VS2010安装项目的系统必备中没有.NET 2.0,不过我们可以从VS2008的程序文件中找到 .NET 2.0 的系统必备安装包。
安装了VS2008 的 C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages 下的 DotNetFX 文件夹,就是 .NET 2.0 的系统必备安装包。把 DotNetFX 文件夹复制到安装了 VS2010 的 C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages下,然后在VS2010中就可以选择 .NET 2.0 的系统必备了。
阅读全文
摘要:/*client*/
public partial class FormClient : Form
{
public FormClient()
{
InitializeComponent();
}
private void btnSend_Click(object sender, EventArgs e)
{
Client client = new Client(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8500));
lblMsg.Text = "服务器IP及端口:" + client.socket.RemoteEndPoint.ToString();
阅读全文
摘要:C#自带DeflateStream,生成后的文件和javat生成的不一样.
阅读全文
摘要:byte[] defArr = File.ReadAllBytes(filePath);byte[] md5Arr = GetMd5Hash(filePath); int len = defArr.Length + md5Arr.Length;byte[] lenArr = BitConverter.GetBytes(len);if (BitConverter.IsLittleEndian) Array.Reverse(lenArr);//resArr为合并后数组byte[] resArr = new byte[lenArr.Length + defArr.Length + md5Arr.Le
阅读全文
摘要:闲来无事,利用WinForm做了个查看SQL Server所有数据库表信息的小工具。总结一下:1、只允许运行应用程序的一个实例.....
阅读全文
摘要:反编译工具ILSpy、LINQ学习工具LINQPad等。。。。。。
阅读全文
摘要:平时用系统自带的记事本记录日常消费,简单快捷但是缺少统计功能,不清楚每个月花费多少,于是写个程序统计一下。
阅读全文
摘要:MSDN:http://msdn.microsoft.com/zh-cn/library/bb549151%28v=VS.90%29.aspx封装一个具有一个参数并返回 TResult 参数指定的类型值的方法。public delegate TResult Func<T, TResult>( T arg)类型参数T 此委托封装的方法的参数类型。 TResult 此委托封装的方法的返回值类型。 参数arg 类型:T 此委托封装的方法的参数。返回值类型:TResult此委托封装的方法的返回值。 备注可以使用此委托表示一种能以参数形式传递的方法,而不用显式声明自定义委托。该方法必须与此委
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Net;using System.Text.RegularExpressions;public partial class Default7 : System.Web.UI.Page{ // C#应用正则表达式将相当路径转化为绝对路径 //(来源:http://code.nontalk.com/2007/0
阅读全文
摘要:/// <summary> /// 判断传入的字符串是否是为整数 /// </summary> /// <param name="strContent">待判断的字符串</param> /// <returns>判断结果</returns> public static bool IsInteger(string strContent) { bool IsInt = false; int result; if (!System.String.IsNullOrEmpty(strContent)) { IsI
阅读全文
摘要:发现对枚举的一些用法还不太熟悉,重新翻看了框架设计(第2版) CLR Via C#一书,整理了一下。声明枚举类型:internal enum Color { White, Red, Green, Blue, Orange }1、Enum类型的静态方法GetUnderlyingType: Public static Type GetUnderlyingType(Type enumType); 该方法返回用于容纳枚举类型值的核心类型。每个枚举类型都有一个基本类型,该类型可以是一个byte,sbyte,short,ushort,int(最常见,也是默认的),uint,long或ulong。 声明一个
阅读全文
摘要:流水号由8位日期加8位顺序号组成,如2010030200000056。先从数据库中取中最大的流水号,和此时要生成的日期比较是否在同一天,是则顺序号加1,否则重新以此时日期生成流水号Oracle sql:select nvl(max(serialnumber),0) as maxSerialNumber from tb /// <summary> /// 生成充值流水号格式:8位日期加8位顺序号,如2010030200000056。 /// </summary> public string GetSerialNumber(string serialNumber) { if
阅读全文
摘要:using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Collections.Gener
阅读全文
摘要:运行结果: 主线程开始 主线程:a 辅助线程开始... 辅助线程:0 主线程:b 主线程:c 辅助线程:1 主线程:d 主线程:e 辅助线程:2 主线程:f 辅助线程:3 主线程:g 主线程:h 辅助线程:4 主线程:i 主线程:j 辅助线程:5 辅助线程:6 辅助线程:7 辅助线程:8 辅助线程:
阅读全文
摘要:using System;using System.Diagnostics; class Program { static void Main(string[] args) { ProcessStartInfo info = new ProcessStartInfo("IExplore.exe"); //准备启动IE info.WindowStyle = ProcessWindowStyle.Maximized; //IE最大化 info.Arguments = "www.google.cn"; //参数 Process.Start(info); //启
阅读全文
摘要:例子1:using System; class Program { public delegate int CalculateDelegate(int min,int max); static void Main(string[] args) { CalculateDelegate d = Calculate; //为了简单,未检查输入是否数字 Console.WriteLine("请输入最小数字:"); int min = int.Parse(Console.ReadLine()); Console.WriteLine("请输入最大数字:"); int
阅读全文
摘要:using System; class Program { public class Cat { private string name; public Cat(string name) { this.name = name; } public delegate void CatCallEventHandler(); //猫叫的委托 public event...
阅读全文
摘要:父类与子类间的隐藏与重写例子(改写一题面试题)(1)隐藏当分别位于父类和子类的两个方法完全一样时,调用哪个方法由对象变量的类型决定。using System; public class A { public A() { Console.WriteLine("A"); } public virtual void Fun() { Console.WriteLine("A.Fun()"); } } public class B : A { public B() { Console.WriteLine("B"); } public new v
阅读全文

浙公网安备 33010602011771号