- 博客(11)
- 资源 (1)
- 收藏
- 关注
原创 C# 排序
<br />1 冒泡排序<br /> class BubbleSorter { public static void Sort(int[] a) { BubbleSort(a); } private static void BubbleSort(int[] myArray) { for (int i = 0; i < myArra
2010-12-28 14:15:00 541
原创 C# 命名规则
1 命名空间,类,方法,以及基类上的成员应使用Pascal规则命名。 Pascal规则是:第一个字母必须大写,并且后面的并发连结词的第一个字母均为大写,例如象GeneralManager、SmallDictionary、StringUtil都是合乎这种规则的类名.如:public class Test{ public void DataBind() { }}2 局部变量和方法中的参数用camel规则命名,并添加数据类型前缀。 camel规则是:第一个子串外的所有子串的第一个字
2010-12-27 21:49:00 1489
原创 Windows窗体Paint()事件
<br />当我们在一个windows窗体作图,在窗体的构造函数中写如下代码<br />public Form1() { InitializeComponent(); Graphics g = this.CreateGraphics(); this.Show(); Pen p1 = new Pen(Color.Blue); g.DrawEllipse(p1,
2010-12-25 20:46:00 10747 1
原创 创建和读写文件的一些简单方法
<br />1 使用StreamWriter向文件写入数据<br />public static void WriteToLog(string logFileName, string data) { using (FileStream fileStream = new FileStream(logFileName, FileMode.Append, FileAccess.Write, FileShare.None)) {
2010-12-22 16:41:00 863
原创 编程创建XML文档
<br />1 用XmlWrite创建XML文档<br />XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; FileStream fs = new FileStream("123.xml", FileMode.Create); using (XmlWriter write=XmlWriter .Create (fs ,set
2010-12-22 10:25:00 488
原创 统计文本行
<br />需要统计一个串或一个文本中的文本行数<br />利用正则表达式来匹配换行符,实现统计<br /> public static long LineCount(string source, bool isFileName) { if (source != null) { string text = source; if (isFileName)
2010-12-19 20:18:00 528
原创 txt文件切割器
自己写的一个文件切割器,不知道为什么只能切割英文文件,中文的不能实现等比例切割。namespace FileCut{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e)
2010-12-19 20:13:00 1418
转载 C# 操作RAR:压缩,解压
<br />using System;using System.Collections.Generic;using System.Text;using System.IO;using Microsoft.Win32;using System.Diagnostics;namespace Uni.UniCustoms{ public class clsWinrar { /// <summary> /// 是否安装了Winra
2010-12-15 13:13:00 746
原创 找出字符在串中的所有出现
<br />在循环中使用IndexOf来确定一个字符出现多少次,并明确分别出现在串中的什位置。<br />1 使用ist<int>来保存找到的字符串的位置,最后一个为找到的字符串的总数<br />public static int[] FindAllOccurrences(char matchChar, string source, int maxMatches, bool caseSensitivity) { List<int> occurrences = ne
2010-12-12 22:00:00 529
原创 创建定制枚举器
<br />若要为类增加foreach支持,可在类中增加一个迭代器,即在类中实现IEnumerable接口。<br />必须实现IEnumerator<T> GetEnumerator()方法。<br />namespace testIEnumberable{ class Program { static void Main(string[] args) { Container <int> cntnr=new Contai
2010-12-09 22:07:00 553
原创 逆置数组
<br />1 快速逆置数组<br /> 可以使用Array中的Reverse方法。如:<br />int[] array = new int[] {1,3,5,4,2 }; Array.Reverse(array); foreach (int n in array) Console.WriteLine(n);<br />2 自己编写一个方法:DoReversal.优点:速度快,支持任何类型,不必装箱和拆箱。<br />
2010-12-05 21:34:00 3016 1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人