title: Java Comparator override equivalent in c#
body: <p>I want to convert the following class from java to C#:</p>
  
  <pre><code>public class ValueComparator implements Comparator{
  
      @Override
      public int compare(Object ob1, Object ob2){
          int retval = 0;
          if ( ob1 instanceof DataCol &amp;&amp; ob2 instanceof DataCol ){
              DataCol c1 = (DataCol) ob1;
              DataCol c2 = (DataCol) ob2;
              if( c1.value &lt; c2.value ) retval = 1;
              if( c1.value &gt; c2.value ) retval = -1;
          } else {
              throw new ClassCastException("ValueComparator: Illegal arguments!");
          }
          return(retval);
      }    
  }
  </code></pre>