代码改变世界

随笔档案-2013年01月

匿名类型与Lambda表达式

2013-01-02 19:57 by 哒不溜, 1559 阅读, 收藏,
摘要: 匿名类型:先上一个匿名类的例子吧:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace DelegateDemo2{ class Program { static void Main(string[] args) { string mid = ",middle part"; //匿名方法的应用,在3.0以后就是用lambda表达式来代替了匿名方法 Func<st... 阅读全文

使用Func<T>对对象进行排序

2013-01-02 14:32 by 哒不溜, 1130 阅读, 收藏,
摘要: 这种方法使用原理还是冒泡排序,但是他扩展的,不仅是对int类型的数据,也可以对其他的一些无法用“<”或“>”来进行排序的对象。代码如下:解决方案的名称:DelegateBubbleSorterBubbleSorter.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace DelegateBubbleSorter{ class BubbleSorter { static public void Sort<T>(IList<T> 阅读全文