Operators Compared in Different Languages

This topic lists the operators for Visual Basic, C++, C#, JScript, and Visual FoxPro.

For details about operators in this language

See

Visual Basic

Operators Summary

C++

C++ Operators

User-Defined Operators

C#

C# Operators

JScript

JScript Operators

Operator Comparisons by Language

 

Visual Basic

C++

C#

JScript

Visual FoxPro

Additive

 

 

 

 

 

  Addition

+

+

+

+

+

  Subtraction

-

-

-

-

-

Multiplicative

 

 

 

 

 

  Multiplication

*

*

*

*

*

  Division

/

/

/

/

/

  Integer division

\

/1

/1

 

 

  Modulus division (returning only the remainder)

Mod (also works with floating point)

%

%

% (also works with floating point)

%

Mod

  Exponentiation

^

n/a

n/a

n/a

^ **

Assignment

 

 

 

 

 

  Assignment

=

=

=

=

=

  Addition

+=

+=

+=

+=

+

  Subtraction

-=

-=

-=

-=

-

  Multiplication

*=

*=

*=

*=

*

  Division

/=

/=

/=

/=

/

  Integer division

\=

n/a

/=1

n/a

n/a

  Exponentiation

^=

n/a

n/a

n/a

n/a

  String concatenation

&=

+=

+=

+=

+

-

$

  Modulus division

n/a

%=

%=

%=

%

  Left shift

<<=

<<=

<<=

<<=

BITLSHIFT( )

  Right shift

>>=

>>=

>>=

>>=

BITRSHIFT( )

  Bitwise AND

n/a

&=

&=

&=

BITAND( )

  Bitwise exclusive OR

n/a

^=

^=

^=

BITXOR( )

  Bitwise inclusive OR

n/a

|=

|=

|=

BITOR( )

  Null coalescing

If( )

n/a

??

n/a

n/a

Relational and equality

 

 

 

 

 

  Less than

<

<

<

<

<

  Less than or equal to

<=

<=

<=

<=

<=

  Greater than

>

>

>

>

>

  Greater than or equal to

>=

>=

>=

>=

>=

  Equal

=

==

==

==

=

  Not equal

<>

!=

!=

!=

<>

#

!=

  Reference variable comparison

Is

IsNot

n/a

==

==

COMPOBJ( )

  Reference type comparison

TypeOf x Is Class1

n/a

x is Class1 (also see as and typeof)

instanceof

n/a

  String comparison

=

Equals

(There are functions to compare and concatenate strings)

==

Equals

==

=

  CString concatenation

&

n/a

+

+

+

  Short circuited Boolean AND

AndAlso

&&

&&

&&

AND

.AND.

  Short circuited Boolean OR

OrElse

||

||

||

n/a

Bit shift

 

 

 

 

 

  Left shift

<<

<<

<<

<<

n/a

  Right shift

>>

>>

>>

>>

>>>

n/a

Scope resolution

 

 

 

 

 

  Scope resolution

.

MyBase

MyClass

::

.

base

n/a

::

Postfix2

 

 

 

 

 

  Array element

( )

[ ]

[ ]

[ ]

[ ]

( )

  Function call

( )

( )

( )

( )

( )

  Type cast or conversion

CInt

CDbl

...

CType

(type)

(type)

type( )

n/a

  Member selection

.

!

.

->

.

.

.

  Postfix increment

n/a

++

++

++

n/a

  Postfix decrement

n/a

--

--

--

n/a

Unary3

 

 

 

 

 

  Indirection

n/a

*

* (unsafe mode only)

n/a

n/a

  Address of

AddressOf

&

& (unsafe mode only; also see fixed)

n/a

n/a

  Logical NOT

Not

!

!

!

!

NOT

.NOT.

  One's complement

Not

~

~

~

BITNOT( )

  Prefix increment

n/a

++

++

++

n/a

  Prefix decrement

n/a

--

--

--

n/a

  Size of type

n/a

sizeof

sizeof

n/a

n/a

  Comma

n/a

,

n/a

,

n/a

Bitwise

 

 

 

 

 

  Bitwise AND

And

&

&

&

BITAND( )

  Bitwise exclusive OR

Xor

^

^

^

BITXOR( )

  Bitwise inclusive OR

Or

|

|

|

BITOR( )

Logical

 

 

 

 

 

  Logical AND

And

&

&

&&

AND

.AND.

  Logical OR

Or

|

|

||

OR

.OR.

Conditional

 

 

 

 

 

  Ternary conditional

If( )

?:

?:

?:

n/a

Pointer to member

 

 

 

 

 

  Pointer to member

n/a

.* ->

. (Unsafe mode only)

n/a

n/a

Reference

 

 

 

 

 

  Reference

n/a

&

n/a (use reference types)

n/a

@

1. The division operator is overloaded to handle both integer and floating-point division, depending on the operands.

2. Postfix operators have the highest order of precedence in expression evaluation.

3. Unary operators appear before the operand and associate from right to left.

See Also

Reference

Programming Concepts Compared in Different Languages with Code Examples

Controls and Programmable Objects Compared in Different Languages and Libraries

Other Resources

Language Equivalents

Change History

Date

History

Reason

August 2008

Updated references to If operator, ^=, and string equality operator in Visual Basic.

Customer feedback.