通过本文主要向大家介绍了c#集合类,c#类代码,c#抽象类,c#类,c#静态类等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
说明:
1、集合类型参数化;
2、可根据集合中的对象的各个属性进行排序,传入属性名称即可;
注:属性必须实现了IComparable接口,C#中int、datetime、string等基本类型都已经实现了IComparable接口。
while (i < j && ((IComparable)propertyinfo.GetValue(key, null)).CompareTo((IComparable)propertyinfo.GetValue(list[i], null)) > 0)
{
i++;
}
if (i < j)
{
list[j] = list[i];
j--;
}
list[i] = key;
}
else