title: How do I overload an operator for an enumeration in C#?
body: <p>I have an enumerated type that I would like to define the <code>&gt;</code>, <code>&lt;</code>, <code>&gt;=</code>, and <code>&lt;=</code> operators for. I know that these operators are implictly created on the basis of the enumerated type (as per the <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/expressions#enumeration-comparison-operators" rel="noreferrer">documentation</a>) but I would like to explictly define these operators (for clarity, for control, to know how to do it, etc...)</p>
  
  <p>I was hoping I could do something like:</p>
  
  <pre><code>public enum SizeType
  {
      Small = 0,
      Medium = 1,
      Large = 2,
      ExtraLarge = 3
  }
  
  public SizeType operator &gt;(SizeType x, SizeType y)
  {
  
  }
  </code></pre>
  
  <p>But this doesn't seem to work ("unexpected token") ... is this possible?  It seems like it should be since there are implictly defined operators.  Any suggestions?</p>