static public int Compare(IList a, IList b, IComparer comparer)
{
if (a == null || b == null) {
return 1;
}
if (a.Count != b.Count) {
return Math.Sign(a.Count - b.Count);
}
int limit = (a.Count < b.Count) ? a.Count : b.Count;
for(int i=0; i < limit; i++) {
if (a[i] is IComparable && b[i] is IComparable) {
int cmp = comparer.Compare(a[i], b[i]);
if (cmp != 0) {
return cmp;
}
}
}
return a.Count - b.Count;
}
第二个if块让我迷惑了好一阵。看mono中已经纠正了,怀疑那段语句是不是在喝酒只有写的。
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/