• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

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.

The VB exclusive or operator Xor, is equivalent to the C# exclusive or operator ^.


Use Instant C# and Instant VB to convert between VB.NET and C#.     

Additional resource: VB.NET and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.