fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Operator overloading

Operator overloading 7 months 2 weeks ago #1

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Offline
  • Posts: 1423
  • Karma: 6
Hello,

is it possible to overload operators? Somewhere in the help it is mentioned, but I was not able to do it.
static method operator == ( self oMaster as efCrmTab, oItem as efCrmTab ) as logic

Thank you very much!

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

Operator overloading 7 months 2 weeks ago #2

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Offline
  • Posts: 1423
  • Karma: 6
Hello,

I have found my error: the word "method" has to be removed:
static operator == ( self oMaster as efCrmTab, oItem as efCrmTab ) as logic

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

Operator overloading 7 months 2 weeks ago #3

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Offline
  • Posts: 1423
  • Karma: 6
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:
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
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

  • Page:
  • 1