Logical Operators Trivia in Vb.Net

Is anybody aware of these two keywords OrElse and AndAlso in Vb.Net.

These keywords were introduced in .Net 2.0 . 

 

Dim myobj As Object

 

If Not IsNothing(myobj) AndAlso myobj.y = 200 Then

Console.WriteLine(

"Hello World")
End If

If the myObj is null or nothing then the If condition  shortcircuits and will not validate the condition myObj.y=200 .

I would advise everybody to use the  andAlso and orElse.  I wonder why it was not introduced  a long time back.

C# by default had this feature  by the use && and ||.  

 

 

Print | posted on Sunday, December 16, 2007 12:22 AM

Comments on this post

No comments posted yet.

Your comment:

 (will show your gravatar)
 
Please add 6 and 5 and type the answer here: