Now that you’ve seen the background information, you can go on to implement some static operator procedures. You’ll use standard math calculation operators in this example.
The example here differentiates between two types: actual operators, such as +, –, *, /, and so on, and operators that are used to convert types. You’ll start with the calculation operators:
Public [Class|Structure] OpType Public Shared Operator OpChar(ByVal objVar1 As [OpType|Type1], ByVal objVar2 As [OpType|Type2]) As Type3 ' Here is the code that performs the actual operation End Operator End [Class|Structure]
The code body illustrates what’s important:
You can apply operators to classes and structures.
Which operator (+,–, *, /, and so on) is used is specified ...