Serwus!
Mam pytanie odnośnie przeciążania operatorów oraz metody Equals. Mam prostą klasę Complex, która odpowiada liczbie zespolonej.
Complex.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Przeciazanie_operatorow.Models
{
class Complex
{
public double Re { get; private set; }
public double Im { get; private set; }
public Complex()
{
Re = Im = 0;
}
public Complex(double re, double im)
{
Re = re;
Im = im;
}
public Complex(Complex c)
{
Re = c.Re;
Im = c.Im;
}
public override string ToString()
{
return (Im >= 0) ? $"{Re} + {Im}i" : $"{Re} - {-Im}i";
}
}
}
Czy w przeciążeniu operatora == ( != też ) powinienem porównywać referencje obiektów czy wartości Re i Im? Co powinienem sprawdzać w metodzie Equals?