title: C# Error: The call is ambiguous between the following methods or properties. Overloading operators
body: <p>I have 2 classes with overloaded operators in a namespace called Dinero, these are the 2 classes:</p>
  
  <p>First one:</p>
  
  <pre><code>namespace Dinero
  {
      class Dollar
      {
          #region Atributos
  
          public Double cant;
  
          #endregion
  
          #region Constructores
  
          public Dollar()
          {
              this.cant = 0;
          }
  
          public Dollar(Double amount)
          {
              this.cant = amount;
          }
  
          #endregion
  
          #region Sobrecarga de Operadores
  
          public static Dollar operator +(Euro eu, Dollar dol)
          {
              Dollar devolucion = new Dollar();
  
              devolucion.cant = eu.cant + (dol.cant * 1.3642);
  
              return devolucion;
          }
  
          public static Dollar operator -(Euro eu, Dollar dol)
          {
              Dollar devolucion = new Dollar();
  
              devolucion.cant = eu.cant + (dol.cant * 1.3642);
  
              return devolucion;
          }
  
          public static bool operator ==(Euro eu, Dollar dol)
          {
              if (eu.cant == (dol.cant * 1.3642))
                  return true;
              else
                  return false;
          }
  
          public static bool operator !=(Euro eu, Dollar dol)
          {
              if (eu.cant != (dol.cant * 1.3642))
                  return true;
              else
                  return false;
          }
  
          #endregion
  
      }
  }
  </code></pre>
  
  <p>Second one:</p>
  
  <pre><code>namespace Dinero
  {
      class Euro
      {
          #region Atributos
  
          public Double cant;
  
          #endregion
  
          #region Constructores
  
          public Euro()
          {
              this.cant = 0;
          }
  
          public Euro(Double amount)
          {
              this.cant = amount;
          }
  
          #endregion
  
          #region Sobrecarga de operadores
  
          public static Euro operator +(Euro eu, Dollar dol)
          {
              Euro devolucion = new Euro();
  
              devolucion.cant = eu.cant + (dol.cant * 1.3642);
  
              return devolucion;
          }
  
          public static Euro operator -(Euro eu, Dollar dol)
          {
              Euro devolucion = new Euro();
  
              devolucion.cant = eu.cant - (dol.cant * 1.3642);
  
              return devolucion;
          }
  
          public static bool operator ==(Euro eu, Dollar dol)
          {
              if (eu.cant == (dol.cant * 1.3642))
                  return true;
              else
                  return false;
          }
  
          public static bool operator !=(Euro eu, Dollar dol)
          {
              if (eu.cant != (dol.cant * 1.3642))
                  return true;
              else
                  return false;
          }
  
          #endregion
  
      }
  }
  </code></pre>
  
  <p>And when I go to the main program ( I don't know how you guys call the main file, I'd like to know since I'm a total n00b ) and I type this:</p>
  
  <pre><code>namespace Ejercicio_21
  {
      class Ejercicio_21
      {
          static void Main(string[] args)
          {
              Console.Title = "Ejercicio Nro 21";
  
              Euro euro00 = new Euro(1);
              Dollar dollar00 = new Dollar(1);
  
              Euro sumaEuros = euro00 + dollar00;
  </code></pre>
  
  <p>About the last line, the compiler says: </p>
  
  <blockquote>
    <p>Error 11  The call is ambiguous between the following methods or
    properties: 'Dinero.Euro.operator +(Dinero.Euro, Dinero.Dollar)' and
    'Dinero.Dollar.operator +(Dinero.Euro, Dinero.Dollar)'</p>
  </blockquote>
  
  <p>I assume it has something to do with the different namespaces, but I couldn't figure it out, even using google.</p>
  
  <p>This is the first question I ask here, so please, don't flame me to oblivion and please excuse my horrid English.</p>
  
  <p>Note: I'm forced to keep Dollar and Euro classes in a different namespace than the main program.</p>
  
  <p>Thank you in advance.</p>