By choice I program in C#, but this month I am working on a couple of consulting projects (hire me!) that use VB.NET. I find myself using the short-circuiting operators - AndAlso and OrElse - quite a bit. There are times when you'd need to use them if you wanted to do something like the following on one line of code:
If reader.Read() AndAlso reader(”FirstName”) = “Scott” then
...
End If
I don't find myself doing things like the above, but I still find myself using AndAlso and OrElse a lot. Simple things, like if I want to only proceed if two Boolean values are true, I'll do:
If bool1 AndAlso bool2 then ...
I'm curious if the everyday / regular VB.NET programmers find themselves using the short-circuiting operators or not. The only reason, I fathom, why you'd not want to use short-circuiting is if the evaluation you were performing had some side-effects, which is a bad programming practice. It's a real shame the VB.NET language designers buckled to the pressure of the VB community and didn't just made And and Or short-circuiting, as initially planned.