Showing posts with label AndAlso. Show all posts
Showing posts with label AndAlso. Show all posts

Friday, March 9, 2007

Equivalent of short-circuiting using - AndAlso && OrELse

The equivalent operators for 'AndAlso' and 'OrElse' of VB.NET in C# are '&&' and '||' respectively.

If your question is what's new about it? Well, for me it was a news. As I always used 'And/Or' in VB and '&&' in C++ or Java, never really cared about the difference between both, as I considered them to be the same. When .NET added the power of 'Also and Else' to these operators in VB, I learnt a better way of comparing and evaluating logical conditions using 'AndAlso' and 'OrElse'. When I started with C#, and came across very first logical comparison, I smartly searched for equivalent of 'AndAlso and OrElse' in C# only to find that they are there since ever in C#. I felt dumbhead. :)

My source of knowledge for this equivalent.

Learn more about AndAlso in VB.NET
Learn more about OrElse in VB.NET