随笔分类 - C#
摘要:private void ReadStreamFromFile() { string filePath = @"D:\abc.txt"; int bufferSize = 1024000; //每次读取的字节数 byte[] buffer = new byte[bufferSize]; System.IO.FileStream stream = null; try { stream = new System.IO.Fi...
阅读全文
摘要:ACCESS数据库在.net程序中相对路径的问题困扰,搞得每次移动程序都要去修改web.config中数据库连接字符串的数据库路径。好多人的web.config中的写法如下:程序中这样写:MyConn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["OLEDBCONNECTIONSTRING"]); //注释一下:VS2005和VS2003中的ConfigurationSettings写法不一样,具体区别自己查吧这样程序运行时经常提示诸如以下的错误:'C:/WI
阅读全文
摘要:csusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page {protected int[] la = new int[]{1,2,3,4,5}; protected void Page_Load(object sender, EventArgs e){ }}aspx
阅读全文
摘要:using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;namespace 英语词频{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ...
阅读全文
摘要:using System; using System.Collections; using System.Linq; using System.Text; using System.IO; using System.Text.RegularExpressions; class getFiles { public static void getWordList(string pathName, ref Hashtable wordList) //getWordList:从文本文件中统计词频保存在Hashtable中 { Strea...
阅读全文
摘要:性能全部损耗在排序上,由于hashtable不能排序,所以只能借助其他来排序,不过还好一本60000字的书10几秒就能统计完.using System.IO;using System.Collections;//use hashtableusing System.Text.RegularExpressions;namespace WindowsApplication1{ public partial class Form1 : Form {public Form1(){InitializeComponent();}private void cmdStart_Click(object sende
阅读全文
摘要:private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = getWordSum(textBox1.Text).ToString(); } private int getWordSum(string text) { string textbasic = text; char[] basictemp = text.ToCharArray(); int ch...
阅读全文
摘要:ArrayList是一种动态数组,其容量可随着我们的需要自动进行扩充.ArrayList位于System.Collections命名空间中,所以我们在使用时,需要导入此命名空间.下面,我们还是在Student类的基础上利用ArrayList操作,从而了解ArrayList的用法public class Student { public Student(){} public Student(String name,int age,String hobby) { ...
阅读全文
摘要:文本的旋转显示 privatevoidForm1_Paint(objectsender,System.Windows.Forms.PaintEventArgse){Graphicsg=e.Graphics;g.SmoothingMode=SmoothingMode.AntiAlias;//声明并初始化Graphics对象gstringtempstr="Hello C#";//取得要显示的文字for(inti=0;i<361;i=i+10){g.TranslateTransform(150,150);g.RotateTransform(i);//将指定的旋转用于g的变换
阅读全文
摘要:在.net 编程环境中,系统的资源分为托管资源和非托管资源。 对于托管的资源的回收工作,是不需要人工干预回收的,而且你也无法干预他们的回收,所能够做的只是了解.net CLR如何做这些操作。也就是说对于您的应用程序创建的大多数对象,可以依靠 .NETFramework 的垃圾回收器隐式地执行所有必要的内存管理任务。 对于非托管资源,您在应用程序中使用完这些非托管资源之后,必须显示的释放他们,例如System.IO.StreamReader的一个文件对象,必须显示的调用对象的Close()方法关闭它,否则会占用系统的内存和资源,而且可能会出现意想不到的错误。 我想说到这里,一定要清楚什么是...
阅读全文

浙公网安备 33010602011771号