Operator Overloading

Top  Previous  Next

New features since Delphi 7 > Operator Overloading

 

 

 

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Operator_Overloading_(Delphi)

 

The following table maps the signatures of Delphi operators to the signatures of the according operators in C#:

 

 

 

Delphi Declaration Signature

Symbol Mapping

C# Declaration Signature

 

 

 

Implicit(a : type) : resultType;

implicit typecast

public static implicit operator resultType (type a)

 

Explicit(a: type) : resultType;

explicit typecast

public static exlicit operator resultType (type a)

Negative(a: type) : resultType;

-

public static type operator - (type a)

Positive(a: type): resultType;

+

public static type operator + (type a)

Inc(a: type) : resultType;

Inc

public static type operator ++ (type a)

Dec(a: type): resultType;

Dec

public static type operator -- (type a)

LogicalNot(a: type): resultType;

not

public static resultType operator ! (type a)

Trunc(a: type): resultType;

Trunc

public static resultType Trunc(type Value)

Round(a: type): resultType;

Round

public static resultType Round(type Value)

In(a: type; b: type) : Boolean;

in

public static bool IsContained(type a, type b)

Equal(a: type; b: type) : Boolean;

=

public static bool operator == (type a, type b)

NotEqual(a: type; b: type): Boolean;

<>

public static bool operator != (type a, type b)

GreaterThan(a: type; b: type) Boolean;

>

public static bool operator > (type a, type b)

GreaterThanOrEqual(a: type; b: type): Boolean;

>=

public static bool operator >= (type a, type b)

LessThan(a: type; b: type): Boolean;

<

public static bool operator < (type a, type b)

LessThanOrEqual(a: type; b: type): Boolean;

<=

public static bool operator <= (type a, type b)

Add(a: type; b: type): resultType;

+

public static resultType operator + (type a, type b)

Subtract(a: type; b: type) : resultType;

-

public static resultType operator - (type a, type b)

Multiply(a: type; b: type) : resultType;

*

public static resultType operator * (type a, type b)

Divide(a: type; b: type) : resultType;

/

public static resultType operator / (type a, type b)

IntDivide(a: type; b: type): resultType;

div

public static resultType operator / (type a, type b)

Modulus(a: type; b: type): resultType;

mod

public static resultType operator % (type a, type b)

LeftShift(a: type; b: type): resultType;

shl

public static resultType operator << (type a, type b)

RightShift(a: type; b: type): resultType;

shr

public static resultType operator >> (type a, type b)

LogicalAnd(a: type; b: type): resultType;

and

public static resultType operator && (type a, type b)

LogicalOr(a: type; b: type): resultType;

or

public static resultType operator || (type a, type b)

LogicalXor(a: type; b: type): resultType;

xor

// doesn't exist

BitwiseAnd(a: type; b: type): resultType;

and

public static resultType operator & (type a, type b)

BitwiseOr(a: type; b: type): resultType;

or

public static resultType operator | (type a, type b)

BitwiseXor(a: type; b: type): resultType;

xor

// doesn't exist

 

 

Examples for:

 

binary operators
unary operators.
conversion operators
Finally there are more operators in Delphi like Trunc or In which aren't operators in C#.

 

 

 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content