title: How to define two possible data type for property
body: <p>I am trying to define an operator overloads in C# for 2 classes: <code>Fraction</code> and <code>BasicFraction</code>.
  On the outside, they act the same, but internally <code>Fraction</code> uses <code>PrimeFactorization</code> (stores number as a list of prime factors) and <code>BasicFraction</code> uses <code>int</code> for storing the nominator and denominator.</p>
  <p>They would follow this interface (if I use JSDoc type definitions):</p>
  <pre class="lang-cs prettyprint-override"><code>public interface IFraction
  {
    public (int|Primefactoriztion) a; // nominator
    public (int|Primefactoriztion) b; // denominator
  }
  </code></pre>
  <p>But since I can't do that like this, is there a simple way to use Fraction and BasicFraction interchangeably?<br />
  I can define all operator overloads for evaluating interactions between <code>int</code> and <code>PrimeFactorization</code>. However, I don't know how to tell C# to accept both to be passed to methods.</p>
  <p>Tl;dr: how to make one property allow 2 data types?</p>
  <p>Notes:</p>
  <ul>
  <li>I am new to advanced C# (I know static typing and basic OOP, but nothing more). I am coming from JS and Python background.</li>
  <li>I know they are probably good libraries with this functionality. I am writing this in order to learn C#, not for production.</li>
  </ul>
  <p>Edit:
  Currently, <code>PrimeFactorization</code> stores factors and their power in <code>Dictionary&lt;int, BasicFraction&gt;</code> (I would use <code>Fraction</code>, but it causes recursion; this is basically the only usage of <code>BasicFraction</code>).</p>