Bookcold

导航

C#委托

委托,就是一个能够表示方法的数据类型。

准备工作,写一个冒泡排序

public static void BubbleSort(int[] items,ComparisonHandler comparionsMethod) { int i; int j; int temp; if (items == null) return; if (comparionsMethod == null) throw new ArgumentNullException("comparionsMehtod"); for (i = items.Length - 1; i >= 0; i--) { for (j = 1; j <= i; j++) { if (comparionsMethod(items[j - 1], items[j])) { temp [...]

posted on 2010-03-16 16:22  bookcold  阅读(97)  评论(0)    收藏  举报