title: C# - implementing an interface
body: <p>I have an assignment where I need to implement an interface (IOrder) within my Polynomial Class.  The purpose of the IOrder is to compare the front Node of a Polynomial with another Polynomial and return a boolean if one is &lt;= to the other.  </p>
  
  <p>Here is the initialization of the IOrder interface:</p>
  
  <pre><code> //Definition for IOrder Interface
          public interface IOrder
          {
              // Declare an interface that takes in an object and returns a boolean value
              // This method will be used to compare two objects and determine if the degree (exponent) of one is &lt;= to the other.
              bool Order(Object obj);
  
          }
  </code></pre>
  
  <p>Here are the basics of my Polynomial Class:</p>
  
  <pre><code>        //Definition for Polynomial Class
          public class Polynomial : IOrder
          {
              //this class will be used to create a Polynomial, using the Term and Node objects defined previously within this application
              //////////////////////////////////
              //Class Data Members/
              //////////////////////////////////
              private Node&lt;Term&gt; front;  //this object will be used to represent the front of the Polynomial(Linked List of Terms/Mononomials) - (used later in the application)
  
              //////////////////////////////////
              //Implemention of the Interfaces
              //////////////////////////////////
              public bool Order(Object obj) //: IOrder where obj : Polynomial 
              {
                  // I know i was so close to getting this implemented propertly
                  // For some reason the application did not want me to downcast the Object into a byte
  
                 // //This method will compare two Polynomials by their front Term Exponent
                 // //It will return true if .this is less or equal to the given Polynomial's front node.
                 if (this.front.Item.Exponent &lt;= obj is byte)
                 {
                     return true;
                 }
  
              }
              //////////////////////////////////
              //Class Constructor
              //////////////////////////////////   
              public Polynomial()
              {
                  //set the front Node of the Polynomial to null by default
                  front = null;
              }
              //////////////////////////////////
  </code></pre>
  
  <p>The problem I'm having is with the implementation of the Order interface within the Polynomial Class.  Just to clarify, each Polynomial has a front Node, and a Node is a Term(Coefficient double, Exponent byte) and also a Node of type next which is used in linking the Terms of a Polynomial.  The Polynomials are then added into a Polynomials  object.  The IOrder is to be used to sort the Polynomials in the list according to the value of the exponent of the front Term.  I think i have to downcast the Object obj in the method in order set it up so that I can compare the Exponent of ".this" Polynomial with the Exponent value of the Polynomial supplied to the method.</p>
  
  <p>Any insight into casting these values correctly would be awesome.
  Thanks in advance.</p>