0
Can I overload the == operator? If yes how?
I tried in the Code Playground but it gave me an error, I tried overloading != but that gave me an error as well.
4 odpowiedzi
+ 2
Yes you can:
https://msdn.microsoft.com/es-es/library/53k8ybth(v=vs.71).aspx
"User-defined value types can overload the == operator"
+ 1
You can't overload == i think but you could override the Equals(object other) method like this:
public override bool Equals(object other)
{
// your custom equality checks here ...
}
+ 1
Thx Alvaro I'll check that out.
0
In Java you can't, I am pretty sure you can't do it in C# either.