In VB.NET, what is the difference between And and AndAlso? Which should I use?
In VB.NET, what is the difference between And and AndAlso ? Which should I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
Andoperator evaluates both sides, whereAndAlsoevaluates the right side if and only if the left side is true.An example:
The above throws an exception if
mystring = NothingThis one does not throw an exception.
So if you come from the C# world, you should use
AndAlsolike you would use&&.More info here: http://www.panopticoncentral.net/2003/08/18/the-ballad-of-andalso-and-orelse/