xsharp.eu • Operator overloading
Page 1 of 1

Operator overloading

Posted: Mon Aug 06, 2018 1:49 pm
by wriedmann
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

Operator overloading

Posted: Mon Aug 06, 2018 2:10 pm
by wriedmann
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

Operator overloading

Posted: Mon Aug 06, 2018 2:20 pm
by wriedmann
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