您的位置:首页 > 编程语言 > C#

AOP C#在行动(续2)

2004-07-06 23:48 323 查看
今天开始写Paser了,不过是从SharpDevelop借过来而已(不想重新发明轮子,^_^)。但是,还是对原先的代码作了一些修改,即使到了RC2了,SharpDevelop的代码中还是存在问题。今天看代码是就发现了两处。比如下面的代码:
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中已经纠正了,怀疑那段语句是不是在喝酒只有写的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: