This forum is meant for questions and discussions about the X# language and tools
wriedmann
Posts: 3700 Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy
Post
by wriedmann » Mon Aug 06, 2018 1:49 pm
Hello,
is it possible to overload operators? Somewhere in the help it is mentioned, but I was not able to do it.
Code: Select all
static method operator == ( self oMaster as efCrmTab, oItem as efCrmTab ) as logic
Thank you very much!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
wriedmann
Posts: 3700 Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy
Post
by wriedmann » Mon Aug 06, 2018 2:10 pm
Hello,
I have found my error: the word "method" has to be removed:
Code: Select all
static operator == ( self oMaster as efCrmTab, oItem as efCrmTab ) as logic
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
wriedmann
Posts: 3700 Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy
Post
by wriedmann » Mon Aug 06, 2018 2:20 pm
Hello,
to complete the issue for others:
If you implement the == operator, you have also to implement the != operator and the Equals() and GetHashCode() methods:
Code: Select all
static operator == ( self oMaster as efCrmTab, oItem as efCrmTab ) as logic
static operator != ( self oMaster as efCrmTab, oItem as efCrmTab ) as logic
public method Equals( oItem as object ) as logic
method GetHashCode() as int
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it