我想将以下类从 java 转换为 C#:
public class ValueComparator implements Comparator{
@Override
public int compare(Object ob1, Object ob2){
int retval = 0;
if ( ob1 instanceof DataCol && ob2 instanceof DataCol ){
DataCol c1 = (DataCol) ob1;
DataCol c2 = (DataCol) ob2;
if( c1.value < c2.value ) retval = 1;
if( c1.value > c2.value ) retval = -1;
} else {
throw new ClassCastException("ValueComparator: Illegal arguments!");
}
return(retval);
}
}