Jeff Johnson [MVP: VB]wrote:
]"Raterus said:
I kinda just stumbled across these operators, they seem great, as you can
forget the second expression depending on the result of the first, but are
there any cons to using these?
Interesting you shouild mention you just "stumbled across" them,
because
they were touted as a new feature of VB.NET. Finally VB got true
short-ciruiting. Perhaps they weren't touted loudly or perhaps you
weren't a
VB6 person and therefore never looked into the "new features" news.
The classic example of the main con to using these operators is when
you do
something stupid like change the state of your application during a
test. In
VB, that would basically mean that your If clause would have to
contain a
function call as one of its (second or later) tests and that function
call
would "do something," like changing the value of a variable, as
opposed to
just testing and returning a result. This is generally considered bad
programming practice anyway, so there is virutally no down side to
these
operators.[/quote:f21cad2431]
They were loudly touted when the operators were still "And" and "Or".
When many old-school VB programmers protested that their 'side-effect'
style of coding would be circumvented, so Microsoft relented and kept
"And" and "Or" behaving as in VB6, i.e., no short-circuiting. Then
the modern programmers protested that they wanted the short
circuiting, so Microsoft relented and added back short circuiting,
but as "AndAlso" and "OrElse" to try to keep everyone happy. (a
classic case illustrating why VB is like it is today).