不同类型数组排序
public class SortHelper<T> where T : IComparable
{
public void BubbleSort(T[] array)
{
for (int i = 0; i < array.Length; i++)
{
for (int j = i + 1; j < array.Length; j++)
{
if (array[i].CompareTo(array[j]) < 0)
{
T temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
SortHelper<int> sort = new SortHelper<int>();
int[] array = { 4, 5, 3, 1, 2 };
sort.BubbleSort(array);
foreach (int item in array)
{
Response.Write(item + "<br/>");
}
Type t = typeof(int);
Assembly asm = t.Assembly;
}