title: Is there a C# generic constraint for "real number" types?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/32664/c-sharp-generic-constraint-for-only-integers">C# generic constraint for only integers</a>  </p>
  </blockquote>
  
  
  
  <p>Greets!</p>
  
  <p>I'm attempting to set up a Cartesian coordinate system in C#, but I don't want to restrict myself to any one numerical type for my coordinate values.  Sometimes they could be integers, and other times they could be rational numbers, depending on context.</p>
  
  <p>This screams "generic class" to me, but I'm stumped as to how to constrict the type to both integrals and floating points.  I can't seem to find a class that covers any concept of real numbers...</p>
  
  <pre><code>public class Point&lt;T&gt; where T : [SomeClassThatIncludesBothIntsandFloats?]  {
      T myX, myY;
  
      public Point(T x, T y) {
          myX = x;
          myY = y;
      }
  }
  
  Point&lt;int&gt; pInt = new Point&lt;int&gt;(5, -10);
  Point&lt;float&gt; pFloat = new Point&lt;float&gt;(3.14159, -0.2357);
  </code></pre>
  
  <p>If I want this level of freedom, am I electing for a "typeof(T)" nightmare when it comes to calculations inside my classes, weeding out bools, strings, objects, etc?  Or worse, am I electing to make a class for each type of number I want to work with, each with the same internal math formulae?</p>
  
  <p>Any help would be appreciated.  Thanks!</p>