随笔分类 -  C#

摘要:/// <summary> /// 实现各种进制间的字符串自由转换 /// </summary> /// <param name="value">数据串</param> /// <param name="fromBase">原来的格式</param> /// <param name="toBase">换成的格式&l... 阅读全文
posted @ 2009-08-13 16:47 起源 阅读(290) 评论(0) 推荐(0)
摘要:基本的SQL语句:1. 检索数据使用查询:SELECT、FROM关键字查看所有:SELECT * FROM <table>选择特定的列:SELECT employeeid, firstname, lastname FROM employees使用WHERE子句:SELECT firstname, lastname, country FROM employees WHERE countr... 阅读全文
posted @ 2009-08-12 16:24 起源 阅读(455) 评论(0) 推荐(0)
摘要:我是用StrongNameIdentityPermissionAttribute来保护部分成员的可访问性的: using System.Security.Permissions; public class Class1 { //可以被任何人调用 public void Sub1() { } //只能被具有指定公匙的assembly的类调用 [StrongNameIdentityPermission... 阅读全文
posted @ 2009-08-08 12:27 起源 阅读(968) 评论(0) 推荐(0)
摘要:有时候我们需要获得网页上的图片,尤其是向验证码这样的图片.这个方法就是将网页上的图片获取到PictureBox中.效果入下图所示.右边是使用Webbrowser控件装载的某网站的注册页面,其中包括了验证码.左边是获取到的验证码,装载在PictureBox中.也许有人会问,通过Webbrowser也能够看到注册页面的验证码为什么还要,在获得这个验证码.原因如下:当你不想让别人知道在做什么的时候需要使... 阅读全文
posted @ 2009-08-08 10:13 起源 阅读(1470) 评论(0) 推荐(0)
摘要:1.向项目中添加Jscript文件//script_1.js-----function doClick1(){ alert("OK1_wufeng");}//script_2.js-----function doClick2(){ alert("OK2");}2.解决方案资源管理器中,右键查看script_1.js和script_2.js的属性,把高级中的“生成操作”属性设... 阅读全文
posted @ 2009-08-01 17:09 起源 阅读(406) 评论(1) 推荐(0)
摘要:protected void RepeaterPost_ItemCommand(object source, RepeaterItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { DbDataRecord dbr = ... 阅读全文
posted @ 2009-06-17 11:24 起源 阅读(405) 评论(0) 推荐(0)
摘要:private string getHtml(string url) { WebClient myWebClient = new WebClient(); byte[] myDataBuffer = myWebClient.DownloadData(url); return Encoding.Default.GetString(myDataBuffer); } 阅读全文
posted @ 2009-06-09 18:01 起源 阅读(371) 评论(2) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Text;using System.Net.Mail;using System.Net;namespace Net.E_Mail{ public class Client { /// <summary> /// 发件人/账号 /// </summary> p... 阅读全文
posted @ 2009-06-04 12:31 起源 阅读(243) 评论(0) 推荐(0)
摘要:protected void Page_Load(object sender, EventArgs e) { Control a = Page.LoadControl("WebUserControl.ascx"); a.ID = "WebUserControl"; this.Page.Controls.Add(a); } 阅读全文
posted @ 2009-05-31 14:05 起源 阅读(650) 评论(1) 推荐(1)
摘要:这些天因为工作需要,要将一些html文件转换为chm文件,当然是需要和程序结合在一起。后来找到NDoc,里头有一段代码是相关的,于是开始分析代码,写完之后,总结:主要是利用微软的hhc.exe来编译html文件,程序需要将具体的数据写入hhp和hhc文件。主要代码如下:public void CompileProject(){Process helpCompileProcess = new Pro... 阅读全文
posted @ 2009-05-31 13:54 起源 阅读(284) 评论(0) 推荐(0)
摘要:①为什么要使用存储过程?因为它比SQL语句执行快.②存储过程是什么?把一堆SQL语句罗在一起,还可以根据条件执行不通SQL语句.(AX写作本文时观点)③来一个最简单的存储过程CREATE PROCEDURE dbo.testProcedure_AXASselect userID from USERS order by userid desc注:dbo.testP... 阅读全文
posted @ 2009-05-29 15:27 起源 阅读(190) 评论(0) 推荐(0)
摘要:C#获取网页源码,自动判断网页字符集编码by 小僧空尽 16. 十二月 2008 02:39转自:http://www.busfly.cn/post/cs-web-WebClient-html.html 最近开始打算重新学习C#,并且尝试做点C#练习。而最让我感兴趣的还是和网站相关的东西。那就做个获取网站源码,采集文章的功能吧。根据网上的资料,使用WebClient来获取源码,很容易就能得到网页源... 阅读全文
posted @ 2009-05-29 15:21 起源 阅读(2186) 评论(1) 推荐(0)
摘要:/// <summary> /// 获取指定路径所指定文件或目录名称 /// 如:C:\windows\test/ 为test ; C:\windows\test\A.doc\ 为A.doc /// </summary> /// <param name="Path">路径</param> /// <returns></returns... 阅读全文
posted @ 2009-05-27 15:40 起源 阅读(457) 评论(1) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Text;namespace LicenseReg{ class StringDeal { /// <summary> /// 分解串 /// </summary> /// <param name="Str">串</param> //... 阅读全文
posted @ 2009-05-27 13:52 起源 阅读(280) 评论(0) 推荐(0)
摘要:CodeProject的这篇文章确实对我有所启迪,http://www.codeproject.com/useritems/SessionWrapper.asp#xx1208856xx。诚如作者所说,我们经常在ASP.NET用许多类似于下面的代码来检测Session中存储的对象,来防止Session过期后存储的变量丢失问题:Int32 nUserID = -1;if ( null != Sessi... 阅读全文
posted @ 2009-05-26 11:21 起源 阅读(331) 评论(0) 推荐(0)
摘要:在用Asp.net做网站中,为了防止sql注入,对于get得到的每个数字值都要对其进行类型检查以前我是这样写的(C#)if (!CheckNum(Request.Querying["ID"])){Response.Redirect("Index.aspx");}bool CheckNum(object o){ bool v=false; if (o!=null && o.tostr... 阅读全文
posted @ 2009-05-24 15:55 起源 阅读(388) 评论(0) 推荐(0)
摘要:1。比较时间大小的实验 string st1="12:13"; string st2="14:14"; DateTime dt1=Convert.ToDateTime(st1); DateTime dt2=Convert.ToDateTime(st2); DateTime dt3=DateTime.Now; if(DateTime.Compare(dt1,dt2)>0) msg... 阅读全文
posted @ 2009-05-24 15:38 起源 阅读(501) 评论(0) 推荐(0)
摘要:c#学习体会:使用 ref 和 out 传递数组(downmoon),希望与大家分享 1、与所有的 out 参数一样,在使用数组类型的 out 参数前必须先为其赋值,即必须由接受方为其赋值。例如: public static void MyMethod(out int[] arr) { arr = new int[10]; // 数组arr的明确委派 } 2、与所有的 ref 参数一样,数组类型的... 阅读全文
posted @ 2009-05-23 21:03 起源 阅读(181) 评论(0) 推荐(0)
摘要:在C#中目前我还没有找到发送消息的类成员函数,所以只能采用通过调用WIN 32 API 的 SendMessage() 函数实现。由于 SendMessage的参数中需要得到窗体的句柄(handler) ,所以又要调用另一个API FindWindow(), 两者配合使用,达到在不同窗体之间的消息发送和接收功能。 另外一个要点是,需要通过重写(Override) 窗体的 DefWndProc() ... 阅读全文
posted @ 2009-05-23 21:01 起源 阅读(731) 评论(0) 推荐(0)
摘要:目前网上流行的所谓"取真实IP地址"的方法,都有bug,没有考虑到多层透明代理的情况。 多数代码类似: string IpAddress = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]!=null && HttpContext.Current.Request.ServerVariables... 阅读全文
posted @ 2009-05-23 20:59 起源 阅读(761) 评论(0) 推荐(1)