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 ||.  

 

 
posted on Sunday, December 16, 2007 12:22 AM | Filed Under [ .NET Framework ]

Comments

No comments posted yet.
Post Comment
Title *
Name *
Email
Url
Comment *
Please add 4 and 2 and type the answer here: