Share via


Operators Compared in Different Languages

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

For details about operators in this language See
Visual Basic Operators Keyword Summary
C++ C++ Operators
C# C# Operators
JScript JScript Operators
  Visual Basic Visual J# C++ C# NEW JScript Visual FoxPro
Additive            
  Addition + + + + + +
  Subtraction - - - - - -
Multiplicative            
  Multiplication * * * * * *
  Division / / / / / /
  Integer division \ n/a   /1    
  Modulus (division returning only the remainder) Mod % % % % (also works with floating point) %; Mod
  Exponentiation ^ n/a   n/a n/a ^, **
Assignment            
  Assignment = = = = = =
  Addition += NEW += += += += +
  Subtraction -= NEW -= -= -= -= -
  Multiplication *= NEW *= *= *= *= *
  Division /= NEW /= /= /= /= /
  Integer division \= NEW n/a n/a /=1 n/a n/a
  Concatenate &= NEW +=   += +=

+
-
$

  Modulus n/a %= %= %= %= %
  Left shift <<=NEW <<= <<= <<= <<= BITLSHIFT( )
  Right shift >>=NEW >>= >>= >>= >>= BITRSHIFT( )
  Bitwise-AND n/a &= &= &= &= BITAND( )
  Bitwise-exclusive-OR n/a ^= ^= ^= ^= BITXOR( )
  Bitwise-inclusive-OR n/a |= |= |= |= BITOR( )
Relational and equality            
  Less than < < < < < <
  Less than or equal to <= <= <= <= <= <=
  Greater than > > > > > >
  Greater than or equal to >= >= >= >= >= >=
  Equal = == == == == =
  Not equal <> != != != != <>; #; !=
  Compare two object reference variables Is == n/a == == COMPOBJ()
  Compare object reference type TypeOf x Is Class1 x instanceof Class1 n/a x is Class1 (also see as and typeof) instanceof n/a
  Compare strings = String.equals() (There are functions to compare and concatenate strings) ==

-or-String.Equals()

== =
  Concatenate strings & +   + + +
  Shortcircuited Boolean AND AndAlso && && && && n/a
  Shortcircuited Boolean OR OrElse || || || || n/a
Shift            
  Left shift <<NEW << << << << n/a
  Right shift >>NEW >> >> >> >>, >>> n/a
Scope resolution            
  Scope resolution . n/a :: . and base n/a ::
Postfix2            
  Array element () [ ] [ ] [ ] [ ] [ ]; ()
  Function call () ( ) ( ) ( ) ( ) ( )
  Type cast Cint, CDbl, ..., CType (type) (type) (type) type() n/a
  Member selection . . . or -> . . .
  Postfix increment n/a ++ ++ ++ ++ n/a
  Postfix decrement n/a -- -- -- -- n/a
Unary3            
  Indirection n/a n/a * * (unsafe mode only) n/a n/a
  Address of AddressOf n/a & & (unsafe mode only; also see fixed) n/a n/a
  Logical-NOT Not ! ! ! ! !
  One's complement Not ~ ~ ~ ~ BITNOT( )
  Prefix increment n/a ++ ++ ++ ++ n/a
  Prefix decrement n/a -- -- -- -- n/a
  Size of type n/a 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 | | | | n/a
Logical            
  Logical-AND And && && && && AND
  Logical-OR Or || || || || OR
Conditional            
  Conditional IIf Function () ?: ?: ?: ?: n/a
Pointer to member            
  Pointer to member n/a n/a .* or -> . (Unsafe mode only) n/a n/a
Reference            
  Reference n/a 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

Language Equivalents | Programming Concepts Compared in Different Languages with Code Examples | Controls and Programmable Objects Compared in Different Languages and Libraries