C#从windows剪贴板粘贴内容using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Data;using System.Windows.Forms;public class MainClass……继续阅读 » 4年前 (2021-03-12) 1499浏览 1188个赞
C# windows form拷贝内容到剪贴板 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Data; using System.Windows.Forms; ……继续阅读 » 4年前 (2021-03-12) 2769浏览 291个赞
C#删除文件和文件夹到回收站的代码using System;using Microsoft.VisualBasic.FileIO;namespace leaver{ class Program { static void Main(string[] args) { Conso……继续阅读 » 4年前 (2021-03-12) 3001浏览 1717个赞
C#使用semaphore 管理异步下载请求 var semaphor = new Semaphore(50, 50); // We allow at most 50 threads for crawling var resultPins = new List<Pin>(); // Results stored ……继续阅读 » 4年前 (2021-03-12) 2120浏览 1202个赞
C#检查字符串是否是合法的URL地址protected string HTTPChecker(string Value) { if ((Value.Substring(0, 7) != "http://") && (Value.Substring(0, 8) != "https://") ) ……继续阅读 » 4年前 (2021-03-12) 2604浏览 352个赞
C#反序列化到类的代码演示using System;using System.Collections.Generic;using System.Linq;using System.Runtime.Serialization.Formatters.Binary;using System.Text;using System.Threading.T……继续阅读 » 4年前 (2021-03-12) 2474浏览 507个赞
C#求n个数中的最大值和最小值using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class Program { ……继续阅读 » 4年前 (2021-03-12) 2047浏览 869个赞
asp.net自带的email组件发送邮件 #region 邮件发送 /// <summary> /// 发送邮件支持HTML格式 先引用System.Net.Mail; /// </summary> /// <param name="MailFrom">发送……继续阅读 » 4年前 (2021-03-12) 2805浏览 653个赞
C#控制键盘按键(大小写按键等)来源:http://blog.csdn.net/limlimlim/article/details/8251498using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy……继续阅读 » 4年前 (2021-03-12) 2183浏览 461个赞
一个汉字转拼音的C#类using System;using System.Text.RegularExpressions;using System.Text;namespace Ming{ public class PinYinHelper { private static int[] pyValue = new……继续阅读 » 4年前 (2021-03-12) 1382浏览 2038个赞
C#编写的一个反向代理工具,可以缓存网页到本地转自:http://www.oschina.net/code/snippet_172400_17195 proxy.ashx 主文件<%@ WebHandler Language="C#" ……继续阅读 » 4年前 (2021-03-12) 3050浏览 2904个赞
C#自定义序列化 ISerializable 的实现转自:http://blog.csdn.net/heavensdoor/article/details/6325169 [Serializable] public class BaseObject { [OptionalField] private ……继续阅读 » 4年前 (2021-03-12) 1221浏览 2905个赞
C#委托(delegate)简单示例:在两个form之间传递数据转自:http://blog.csdn.net/jcx5083761/article/details/8484958      ……继续阅读 » 4年前 (2021-03-12) 1231浏览 2346个赞
C#按照指定的长度在数字前补0的两种方法例如123可以转换成000123String snum = "123"; //方法1String pnum = snum.PadLeft(6, '0'); //方法2String fnum = String.Format("{0:000000}"……继续阅读 » 4年前 (2021-03-12) 1540浏览 2250个赞
C#通过 Html Agility Pack(HAP)解析html代码Why Html Agility Pack? (以下简称HAP).Net下解析HTML文件有很多种选择,包括微软自己也提供MSHTML用于manipulate HTML文件。但是,经过我一段时间的搜索,Html Agility Pack浮出水面:它是Stackoverflow网站上推荐最多……继续阅读 » 4年前 (2021-03-12) 1821浏览 2259个赞
此代码演示了如何读取和写入注册表 读取注册表 private string GetRegistShellData(string RegistName) { try { strin……继续阅读 » 4年前 (2021-03-12) 2321浏览 1845个赞
C# 操作系统服务(service)代码可以控制启动和停止系统服务 private bool StopService(string StopServiceName) { ServiceController service = new ServiceController(StopServiceName); ……继续阅读 » 4年前 (2021-03-12) 2529浏览 2701个赞
这段代码演示了如何根据进程名关闭进程和启动进程 private bool CloseProcess(string CloseProcessName) { try { //根据进程名称,获取该进程信息 Process[] MyP……继续阅读 » 4年前 (2021-03-12) 2847浏览 1604个赞
C# 判断指定URL地址是否可以正常访问如果只是判断url是否存在,不需要抓取整个url,只需要通过head方式请求即可HttpWebRequest myRequest= (HttpWebRequest)WebRequest.Create(url);myRequest.Method="HEAD"; ……继续阅读 » 4年前 (2021-03-12) 2349浏览 389个赞
如果要遍历hashtable可以通过GetEnumerator()进行迭代遍历,但是由于hashtable的数据在不断变化,在遍历过程中就可能报错,最好的办法就是先复制一个新的HashTable,然后再遍历,我没有找到完整复制的办法,但HashTable提供了一个clone,浅表复制,基本也可以解决问题。Hashtable ht = (Hashtabl……继续阅读 » 4年前 (2021-03-12) 1764浏览 850个赞
枚举数可用于读取集合中的数据,但不能用于修改基础集合。最初,枚举数定位在集合中第一个元素前。Reset 方法还会将枚举数返回到此位置。在此位置上,Current 属性未定义。因此,在读取 Current 的值之前,必须调用 MoveNext 方法将枚举数提前到集合的第一个元素。在调用 MoveNext 或 Reset 之前,Current 返回同一对象。Mo……继续阅读 » 4年前 (2021-03-12) 2801浏览 967个赞
面的示例说明如何将 Hashtable 中键的列表或值的列表复制到一维 Array 中。转自:微软MSDNusing System;using System.Collections;public class SamplesHashtable { public static void Main() { // Creates an……继续阅读 » 4年前 (2021-03-12) 2368浏览 2185个赞
此代码可以将hashtable中的值通过copyto转换到一个一维数组var length = ht.Count;Guest[] array = new Guest[length];ht.Values.CopyTo(array, 0); 其中ht为hashtable,其key……继续阅读 » 4年前 (2021-03-12) 2342浏览 1332个赞
C#通过SendMessage进行进程间通信http://blog.csdn.net/bluceyoung/article/details/8477315 为了深入理解消息机制,先来做一个测试项目在新建项目的Form1的代码中,加入方法:protected override vo……继续阅读 » 4年前 (2021-03-12) 2270浏览 2410个赞
C#:DataGridView中列类型使用时间控件和下拉列表的自动匹配来源:http://blog.csdn.net/kingzone_2008/article/details/84706661. DataGridView中使用时间控件作为列类型DataGridView中默认不提供DateTimePicker类型的列类型,因此可以通过控件的覆盖模拟……继续阅读 » 4年前 (2021-03-12) 3174浏览 663个赞
C#遍历HashTable的两种方法 方法一 foreach (System.Collections.DictionaryEntry objDE in objHasTab){ Console.WriteLine(objDE.Key.ToString()); Con……继续阅读 » 4年前 (2021-03-12) 1418浏览 2149个赞
题目:一个大小为N的数组,里面是N个整数,怎样去除重复,要求时间复杂度为O(n),空间复杂度为O(1). 转自:http://blog.csdn.net/hawksoft/article/details/6867493 //下面的思路没问题,但算法有问题,修正后的算法见后面. /// <summary> ……继续阅读 » 4年前 (2021-03-12) 2408浏览 1578个赞
C#获取页面的执行时间protected DateTime dt; protected void Page_Load(object sender, EventArgs e) { } protected override void OnPreInit(EventAr……继续阅读 » 4年前 (2021-03-12) 2926浏览 2468个赞
C# 内置队列类Queue使用范例,本范例详细演示了C#内置的队列如何进行添加,移除等功能。来自微软MSDNusing System;using System.Collections.Generic;class Example{ public static void Main() { Queue<string……继续阅读 » 4年前 (2021-03-12) 3082浏览 1837个赞
C# 按照字符串对一个长字符串进行分割这个方法性能不是很好,但是也算是一朵奇葩转自:http://blog.csdn.net/sundacheng1989/article/details/8036194 string字符串有根据一个char来分割成子字符串数组的方法string t……继续阅读 » 4年前 (2021-03-12) 1781浏览 2736个赞
C# 通过oledb读取excel表格内容到datatablehttp://blog.csdn.net/sundacheng1989/article/details/8463341 首先看一段实例代码string strCon = @"Provider=Microsoft……继续阅读 » 4年前 (2021-03-12) 2055浏览 2165个赞
C#中枚举类型和radiobox关联操作代码有了enum我们可以列举类型了,有了单选框和复选框我们可以鼠标来选择了。但是编程的时候觉得让两个关联起来,写代码比较麻烦,所以想自动的关联起来。所以我尝试了一下,记录如下。转自:http://blog.csdn.net/callmeback/article/details/8462457假如一个星期的enum:……继续阅读 » 4年前 (2021-03-12) 2864浏览 643个赞
C#演示设计模式之简单工厂模式工厂模式是创建型模式。简单工厂是最简单的模式,主要是静态创建类型转自:http://blog.csdn.net/callmeback/article/details/8462510 #region 简单工厂 public abstract class 产品 { public abstract string 展示()……继续阅读 » 4年前 (2021-03-12) 2839浏览 341个赞
不管什么编程语言都会提供操作Excel文件的方式,C#操作Excel主要有以下几种方式:1.Excel 说明:利用Office 的Excel组件来操作excel文件优点:能够完全操作Excel文件,生成丰富文件内容缺点:需要电脑安装Excel,会启动Excel进程这在web上很不方便2.OpenXML说明:一个操作字处理文档的组件包括Excel优点:能够……继续阅读 » 4年前 (2021-03-12) 1729浏览 528个赞
C#判断一个字符串是否包含另外一个字符串的简单方法string a="china";string b="i";if (a.IndexOf(b) > -1){ //包含指定的字符串,执行相应的代码}……继续阅读 » 4年前 (2021-03-12) 1827浏览 2071个赞
C#通过IHttpModule接口修改http输出转自:http://blog.csdn.net/niuguangyuan/article/details/8458945using System;using System.Collections.Generic;using System.Linq;using System.Web;//修改htt……继续阅读 » 4年前 (2021-03-12) 2236浏览 2617个赞
C#给图片加水印的简单代码 实现本网站图片保护功能 类:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Drawin……继续阅读 » 4年前 (2021-03-12) 2509浏览 1912个赞
C# log4net 配置及使用详解本程序演示如何利用log4net记录程序日志信息。log4net是一个功能著名的开源日志记录组件。利用log4net可以方便地将日志信息记录到文件、控制台、Windows事件日志和数据库(包括MS SQL Server, Access, Oracle9i,Oracle8i,DB2,SQLite)中。并且我们还可以记载控制要……继续阅读 » 4年前 (2021-03-12) 2353浏览 1259个赞
ArrayList是一种动态数组,其容量可随着我们的需要自动进行扩充.ArrayList位于System.Collections命名空间中,所以我们在使用时,需要导入此命名空间.下面,我们还是在Student类的基础上利用ArrayList操作,从而了解ArrayList的用法转自:http://www.cnblogs.com/lihaozy/archive……继续阅读 » 4年前 (2021-03-12) 1219浏览 1420个赞
c# 使用AForge.NET操作摄像头操作代码AForge.NET是一个专门为开发者和研究者基于C#框架设计的,这个框架提供了不同的类库和关于类库的资源,还有很多应用程序例子,包括计算机视觉与人工智能,图像处理,神经网络,遗传算法,机器学习,机器人等领域。 来源:http://blog.csdn.net/gdjlc/article/details/844……继续阅读 » 4年前 (2021-03-12) 2619浏览 1257个赞
C#删除字符串中重复的字符 Func<string, string> RemoveDuplicate = delegate(string s){ BitArray _arr = new BitArray(256); StringBuilder _sb = new StringBuilder(); s = s.ToL……继续阅读 » 4年前 (2021-03-12) 1589浏览 2027个赞
C#封装的Sqlite访问类,要访问Sqlite这下简单了,直接调用此类中的方法即可using System;using System.Collections;using System.Collections.Specialized;using System.Data;using System.Configuration;using Syst……继续阅读 » 4年前 (2021-03-12) 2768浏览 1930个赞
asp.net(C#)判断指定的文件是否存在//文件不存在就创建if(!File.Exists(System.Web.HttpContext.Current.Server.MapPath(path))){ File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close……继续阅读 » 4年前 (2021-03-12) 2573浏览 2867个赞
C#实现的windows form 倒计时using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Window……继续阅读 » 4年前 (2021-03-12) 1232浏览 2351个赞
在vs中,有一个经典的Microsoft.VisualBasic.dll的VB类库,根据官方的描述: 它能提供对许多 .NET Framework 类的简单直观的访问,使您能够编写可与计算机、应用程序、设置、资源等交互的操作及方法代码。 我们可以在项目中引用Microsoft.VisualBasic.dll就可以了实现简体繁体转换方法:……继续阅读 » 4年前 (2021-03-12) 3136浏览 306个赞