摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication2{ class Program { static void ConversString(string str) { if (str.Length == 1) { Console.Write(str); } else ... 阅读全文
posted @ 2013-11-03 19:36 zzunstu 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 1.匿名方法myTime.Elspsed +=delegate(object source, ElapsedEventArgs e){ Console.WriteLine((source as Timer).Interval);};2.把Lamdba表达式用于匿名方法myTime.Elspsed += (source,e) => Console.WriteLine((source as Timer).Interval);Lamdba表达式由三部分组成:放在括号中的参数列表=>运算符C#语句using System;using System.Collections.Generic;u 阅读全文
posted @ 2013-11-03 18:30 zzunstu 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 1.扩展方法可以扩展类型的功能,但无需修改类型本身,甚至可以使用扩展方法扩展不能修改的类型。为了扩展类型的功能,需要通过可以通过该类型的实例调用的方法,为此创建的方法称为扩展方法,他可以带任意数量的参数,返回类型。创建一个非泛型静态类使用扩展方法的语法,给创建的类添加扩展方法;通过扩展类型的一个实例调用扩展方法,与调用扩展类型的其他方法一样;要求如下:方法必须是静态的;方法必须包含一个参数,表示调用扩展方法的类型实例;实例参数必须是为方法定义的第一个参数除了this关键字之外,实例参数不能有其他的修饰符using System;using System.Collections.Generic; 阅读全文
posted @ 2013-11-03 16:44 zzunstu 阅读(531) 评论(0) 推荐(0) 编辑
摘要: C#4.0引入了命名参数,它允许指定要使用哪个参数。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace NamedPara{ public static class WordProcessor { private const bool defaultval = false; public static List GetWords( string sentence, bool cap... 阅读全文
posted @ 2013-11-03 16:07 zzunstu 阅读(393) 评论(0) 推荐(0) 编辑