📄 descendingcomparer.cs
字号:
using System;
using System.Collections;
namespace MSPress.CSharpCoreRef.ch08Comparer
{
public class DescendingComparer: IComparer
{
public int Compare(object x, object y)
{
int result = 0;
if(x == null && y == null)
result = 0;
else if(y == null)
result = -1;
else if(x == null)
result = 1;
else
{
if(x.GetType() != y.GetType())
throw new ArgumentException("Invalid comparison");
IComparable comp = y as IComparable;
if(comp == null)
throw new ArgumentException("Invalid comparison");
result = comp.CompareTo(x);
}
return result;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -