随笔分类 -  C#

摘要:有时候,为了完成一些window的一些操作,需要引入一些dll进行操作1) 引入系统api进行操作,形如[DllImport("urlmon.dll", CharSet = CharSet.Ansi)] ,包括findWindow找到窗口句柄,以及下面的改变浏览器的UserAgent [DllImp... 阅读全文
posted @ 2014-04-23 09:31 youhumian 阅读(378) 评论(0) 推荐(0)
摘要:using mshtml;using System;using System.Collections.Generic;using System.Linq;using System.Security.Permissions;using System.Text;using System.Threadin... 阅读全文
posted @ 2014-04-18 17:39 youhumian 阅读(562) 评论(0) 推荐(0)
摘要:8.4.2 Hashtable的代码实现 哈希表的实现较为复杂,为了简化代码,本例忽略了部分出错判断,在测试时请不要设key值为空。1 using System;2 public class Hashtable3 {4 private struct bucket5 {6 public Object key; //键7 public Object val; //值8 public int hash_coll; //哈希码9 }10 private bucket[] bucke... 阅读全文
posted @ 2013-10-14 15:30 youhumian 阅读(1217) 评论(0) 推荐(0)
摘要:System.Collections 命名空间包含接口和类,这些接口和类定义各种对象(如列表、队列、位数组、哈希表和字典)的集合。System.Collections.Generic 命名空间包含定义泛型集合的接口和类,泛型集合允许用户创建强类型集合,它能提供比非泛型强类型集合更好的类型安全性和性能。System.Collections.Specialized 命名空间包含专用的和强类型的集合,例如,链接的列表词典、位向量以及只包含字符串的集合。(一)ArrayList 类:使用大小可按需动态增加的数组。using System;using System.Collections.Generic 阅读全文
posted @ 2013-10-14 14:57 youhumian 阅读(181) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Newoverride{ class Dad { public Dad() { Console.WriteLine("Dad construtor"); } public virtual void method() { Console.WriteLine("Dad method"); } } class SmallSon : Dad { public SmallSon() 阅读全文
posted @ 2013-10-02 13:46 youhumian 阅读(162) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2013-07-22 22:00 youhumian 阅读(194) 评论(0) 推荐(0)
摘要://BitMap 位图,常用的方法,Save:主要方式有:(1)保存在图像文件里,可以指定格式[gif,bmp];(2) 保存在流中,以指定格式[gif,bmp]//graphic图像操作对象画图片的边框线graphic.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);画文本 Font font = new Font("Arial", 12, (FontStyle.Bold | FontStyle.Italic));LinearGradientBrush brush 阅读全文
posted @ 2013-07-22 21:48 youhumian 阅读(396) 评论(0) 推荐(0)
摘要:1、C#创建验证码1.1 创建获取验证码页面(ValidateCode.aspx)[html] view plaincopyprint?获取验证码获取验证码 获取验证码 获取验证码 1.2 编写获取验证码代码(ValidateCode.aspx.cs)[csharp] view plaincopyprint?/// ///验证码类型(0-字母数字混合,1-数字,2-字母) /// privatestringvalidateCodeType="0";/// ///验证码字符个数 /// privateintvalidateCodeCount=4;/// ///验... 阅读全文
posted @ 2013-07-22 21:41 youhumian 阅读(456) 评论(0) 推荐(0)
摘要://流操作 // ------------------------------------------------------------------------------------------ //FileStream 针对字节操作;只能进行读或取操作,不能同时进行读取操作, //readByte 如果没有返回-1,自动将位置定位到下一个字节 //flush 写操做是在关闭流之后完成的,如果想及时的写入,用flush FileStream fs = new FileStream(@"D:\a.txt", FileMode.Open); fs.WriteByte(90) 阅读全文
posted @ 2013-07-12 16:33 youhumian 阅读(264) 评论(0) 推荐(0)
摘要:输入输出流的继承结构输入输出常用方法:void Close()关闭流void Flush()清理流中的内容int ReadByte()返回一个整数表示输入的字节数,如果没有数据返回 -1int Read(byte[ ] buf,int offset, int numBytes)将numBytes个字节读入到byte[ ]的以offset为,起始位置,返回读入成功的字节数Long Seek(long offset,SeekOrigin origin)将当前位置定位到以origin为初始位置以后的offset处void WriteByte(byte b)将单个字节写入到一个输出流void Writ 阅读全文
posted @ 2013-07-11 20:43 youhumian 阅读(252) 评论(0) 推荐(0)
摘要:// 由于File.Create方法默认向所有用户授予对新文件的完全读/写访问权限, //所以文件是用读/写访问权限打开的,必须关闭后才能由其他应用程序打开。 //为此,所以需要使用FileStream类的Close方法将所创建的文件关闭。 //File只能被一个流读写,用完需要关闭。 //FileStream和Stream的区别 //FileStream对象表示在磁盘或网络路径上指向文件的流。 //这个类提供了在文件中读写字节的方法,但经常使用StreamReader或StreamWriter执行这些功能。 //这是因为FileStream类操作的是字节和字节数组,而Stream类操作的.. 阅读全文
posted @ 2013-07-07 18:18 youhumian 阅读(315) 评论(0) 推荐(0)
摘要://字符串 string strTest = "123stre汉字"; //insert 在索引位置前面插入 Console.WriteLine(strTest.Insert(1, "5")); //remove 删除从指定索引开始的指定个数的字符串 Console.WriteLine(strTest.Remove(3, 3)); //replace 当没有匹配时,返回本身字符串 Console.WriteLine(strTest.Replace("1234", "456")); //length 长度:一个汉字按 阅读全文
posted @ 2013-07-06 13:06 youhumian 阅读(211) 评论(0) 推荐(0)