Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

Logical Operator Equivalents in VB and C#

A common misconception is that C# has short-circuiting logical operators while VB doesn't.  This is false - both VB and C# have short-circuiting and non-short-circuiting logical operators.

The VB short-circuiting logical operators are AndAlso and OrElse.  The VB non-short-circuiting logical operators are And and Else, which are also overloaded to serve as bitwise operators.

The C# short-circuiting logical operators are && and ||.  The C# non-short-circuiting logical operators are & and |, which are also overloaded to serve as bitwise operators.

The C# equivalent to the VB And operator is the C# & operator, while the C# equivalent to the VB Or operator is the C# | operator.  The C# equivalent to the VB AndAlso operator is the C# && operator, while the C# equivalent to the VB OrElse operator is the C# || operator.

If you need to convert between VB and C# and you are depending on the results being reliable and accurate, then you will want to have Instant C#, the best VB to C# converter, or Instant VB, the best C# to VB converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.