摘要: 一、事件初印象 首先看个播放器的案例 1 class Program 2 { 3 static void Main(string[] args) 4 { 5 MP3 m = new MP3(); 6 7 //启动前 8 m.BeforeStartMP3 = () => { Console.Write 阅读全文
posted @ 2017-05-02 18:30 wesley1680 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 一、扩展方法引入 有个Person类,里面的成员如下: 1 public class Person 2 { 3 public string Name { get; set; } 4 5 public void SayHi() 6 { 7 Console.WriteLine("hello, i am 阅读全文
posted @ 2017-05-02 17:49 wesley1680 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1 ////T必须是值类型 2 //public class MyClass<T> where T:struct 3 //{ 4 5 //} 6 7 //T必须是引用类型 8 //public class MyClass<T> where T : class 9 //{ 10 11 //} 12 1 阅读全文
posted @ 2017-04-30 18:18 wesley1680 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 一、Action(没有返回值的委托,参数可有可无) 1.Action是无参无返回值的委托,用法如下:(非泛型Action) 1 //无参无返回值的Action 2 Action a = () => { Console.WriteLine("这是无参数无返回值的Action"); }; 3 a(); 阅读全文
posted @ 2017-04-30 15:41 wesley1680 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 一、引言 前面我们学过泛型集合List,非泛型集合ArrayList,了解到创建List集合的时候,需要指定类型,并且只能存储这种类型的数据,相比ArrayList能存储各种类型的数据而言,效率更高(避免了装箱拆箱)。那我们声明List<int>集合的时候,开始为何不直接设计一个ListInt类,而 阅读全文
posted @ 2017-04-28 18:18 wesley1680 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 首先定义两个委托和几个方法,后面会用到。 委托: 1 public delegate void M1Delegate(); 2 3 public delegate int M2Delegate(int x,int y); 方法: 1 static int A1(int x,int y) 2 { 3 阅读全文
posted @ 2017-04-28 17:15 wesley1680 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 一、匿名方法的引入 先写几个委托,后面的代码中会调用。 1 public delegate void DelegateM1(); 2 3 public delegate int DelegateM2(int n1,int n2); 4 5 public delegate int DelegateM3 阅读全文
posted @ 2017-04-27 15:12 wesley1680 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 一、委托案例引入 1.案例一: 首先新建一个控制台项目委托案例一,一个类库委托类库一,在类库一中的类Class1中编写Do()方法。然后在控制台项目委托类型一种输出,代码如下: Class1中的代码: 1 namespace 委托类库一 2 { 3 public class Class1 4 { 5 阅读全文
posted @ 2017-04-25 19:24 wesley1680 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 一、概念 正则表达式是用来表示字符串特征的表达式。它说明了字符串中那些字符是必须有的,哪些是可能出现的,哪些是不能出现的。 二、元字符 1) . 表示一个字符。如:a.b,表示ab之间有一个除了\n外的单个字符。 2)[] 表示 字符的筛选。括号中的字符任选一个。 3)[^] 除了括号中的字符,任选 阅读全文
posted @ 2017-04-05 16:39 wesley1680 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 压缩 先读取,再写入。只是在写入的时候,需要根据规则写入,如果用用压缩流写入,就成了压缩。 1 using (FileStream fs = new FileStream("yasuo.txt", FileMode.Open, FileAccess.Read)) 2 { 3 byte[] buffe 阅读全文
posted @ 2017-03-28 18:56 wesley1680 阅读(215) 评论(0) 推荐(0) 编辑