Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Why in overloading?

$
0
0

Hi,

I implementation operator overloading in c#.

I overload '>=' . why i force implementation '<= ' .  :(

The comparison operators, if overloaded, must be overloaded in pairs; that is, if== is overloaded, != must also be overloaded. The reverse is also true, and similar for< and >, and for<= and >=.

Why??????????????

Or

// Overloading '+' operator: public static ComplexNumber operator+(ComplexNumber a, ComplexNumber b)
    {return new ComplexNumber(a.real + b.real, a.imaginary + b.imaginary);
    }// Overloading '-' operator: public static ComplexNumber operator-(ComplexNumber a, ComplexNumber b)
    {return new ComplexNumber(a.real - b.real, a.imaginary - b.imaginary);
    }



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>