2008-4-18 11:57:25
public static String[] RemoveDup(String[] myData) { if (myData.Length > 0) { Array.Sort(myData); int size = 1; for (int i = 1; i < myData.Length; i++) if (myData[i] != myData[i - 1]) size++; String[] myTempData = new Str.. |
2008-4-11 11:52:11
//需要添加System.Drawing及System.Windows.Forms引用 using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Windows.Forms; namespace 网页截图 { class Program { [STAThread] static void Main(string[] args) { string url = ".. |
2008-4-11 11:38:17
昨天在调试一个:C#实现网页截图程序时出现下边这个提示 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“8856f961-340a-11d0-a96b-00c04fd705a2”。 一直找不出什么原因,本以为是命令行模式没法解决只能在form下操作,但怎么也想不明白,今天看一文章时突然看到 [STAThread] //这个跟线程有关,并.. |
2008-4-10 12:59:09
using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace 线程练习 { class Program { static void Main(string[] args) { Console.WriteLine("开始一个新的线程,名为次线程"); Thread t = new Thread(new ThreadStart(ThreadProc)).. |
2008-4-7 17:13:32
//C#读取表某个表的字段 private void MSSQL_CONN() { //MSSQLSQL标准连接方式 string strConnection = "user id=sa;password=yongfa365;initial catalog=Northwind;Server=yongfa365;Connect Timeout=30"; SqlConnection conn = new SqlConnection(strConnection); conn.Open(); SqlComma.. |
2008-4-7 13:53:59
ExecuteReader 要求已打开且可用的连接。连接的当前状态为已关闭。, 很可能的原因是: OleDbConnection conn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source="+Server.MapPath("XXX.mdb")); OleDbDataAdapter mydata=new OleDbDataAdapter(_sql,conn); conn.Open() //这句.. |
2008-4-4 21:07:18
感觉C#的正则表达式用起来还是方便些,VBS正则必须得先建一个类的实例。而C#可以直接使用Regex,这个叫静态类,可以直接使用,具体怎么讲以后慢慢学。
要使用正则表达式得先: using System.Text; using System.Text.RegularExpressions; |
2008-4-4 17:36:53
/// <summary> /// winform 读文件 by www.yongfa365.com /// </summary> /// <param name="filename">默认读取的文件名</param> /// <returns></returns> public string ReadFile(string filename) { ////////////////////////读文件操作//////////////////////// string html = ""; OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "打开一个文本文件"; dlg.FileName = filename; dlg.Filter = "所有文件(*.*)|*.*|文本文件 (*.txt)|*.txt;*.ini;*.sql"; if (dlg.ShowDialog() == DialogResult.OK) { filename = dlg.FileName; StreamReader din = new StreamReader(filename, System.Text.Encoding.Default); while (din.Peek() > -1) { html = html + din.ReadToEnd(); } din.Close(); } return html; } |
2008-4-4 17:20:39
//编码问题目前为止,基本上没人解决,就连windows的IE的自动识别有时还识别错编码呢。--yongfa365 //如果文件有BOM则判断,如果没有就用系统默认编码,缺点:没有BOM的非系统编码文件会显示乱码。 //调用方法: EncodingType.GetType(filename) //来源:http://blog.csdn.net/listlofusage/archive/2007/02/10/1506900.aspx |
2008-4-4 15:00:12
StreamReader din = new StreamReader(@"C:\1.txt", System.Text.Encoding.GetEncoding("gb2312")); string html = ""; while (din.Peek() > -1) { html = html + din.ReadToEnd(); } din.Close(); |
2008-4-4 14:34:15
柳永法 最常用的快捷键
Alt + Shift + Enter 全屏,第二次退出全屏
Ctrl + E,D Ctrl + K,D 格式化当前所有代码
Ctrl + E,F Ctrl + K,F 格式化选中代码
Ctrl + E,C Ctrl + K,C 批量注释
Ctrl + E,U Ctrl + K,U 批量取消注释
Ctr + Shift + U Ctr + U 对选定的字符串进行大写小写的切换.
F7 从设计模式到代码模式 Shift + F7 从代码模式到设计模式
在任意位置:Ctrl + Enter,当前行上边加一空行,同时光标定位 在任意位置:Ctrl + Shift + Enter,当前行下边加一空行,同时光标定位
Ctrl + K + K :收藏(Bookmark)
F5调试 Shift + F5 退出调试
Ctr+G 查找某行。 |
2008-4-3 13:33:02
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start("Iexplore.exe", "http://www.yongfa365.com"); //在当前窗口打开 //System.Diagnostics.Process.Start("http://www.yongfa365.com"); //如果在新窗口中打开可以加上要执行的文件及参数的形式 //System.Diagnostics.Process.Start("Iexplore.exe", "http://www.csdn.net"); //System.Diagnostics.Process.Start("cmd", "/k echo 'ok'"); //System.Diagnostics.Process.Start("explorer", "C:\\windows\\system32"); //System.Diagnostics.Process.Start("shutdown","/l");//------------注销计算机 //System.Diagnostics.Process.Start("shutdown","/r");//------------重起计算机 } |
2008-5-4 17:47:15
using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Text.RegularExpressions; using System.IO; using System.Net;
namespace 采集测试 { class Program { static void Main(string[] args) { string[].. |
|
|
| |
文章分类 |
|
|
|