C#
int[] arr = new int[2];
//Array类有一个静态方法Sort
//参数是 Sort(Array,泛型参数的方法)
Array.Sort(arr, delegate(int a, int b)
{
int a1 = arr[0];
return a.CompareTo(b);
});
//net3的lamuda表达式
Array.Sort(init, (a, b) => a.CompareTo(b));
//net3的linq扩展方法
var list= init.OrderBy(c=>c).ToArray();
//net3的linq查询
var list=from p in init orderby p select p;
Sort 方法
public static void Sort<T>(T[] array, Comparison<T> comparison);
Comparison 在System名称空间下的一个委托
namespace System
{
// Summary:
// Represents the method that compares two objects of the same type.
//
// Parameters:
// x:
// The first object to compare.
//
// y:
// The second object to compare.
//
// Type parameters:
// T:
// The type of the objects to compare.
//
// Returns:
// Value Condition Less than 0 x is less than y. 0 x equals y. Greater than
// 0 x is greater than y.
public delegate int Comparison<T>(T x, T y);
}
直接看一个线程接口 Runnable
new Runnable(){
public void run()
{
}
};