using VB.Net And/Or operators for logical short-circuiting: Any compiler-directive/workaround?
I found using AndAlso/OrElse, all the time, VERY annoying. It reduces code readability, especially when condit开发者_C百科ioning get complicated.
Any suggestions?
I'm fairly sure there's no (supported) way to change the meaning of And
/Or
, and assuming that your code might in the future be maintained or read by other people it would be a very bad idea, you'd confuse them completely.
If conditioning gets too complicated I'd suggest instead splitting it up on multiple lines.
so instead of:
If x AndAlso y AndAlso (z Or w) Then
Make it something like:
xy = x AndAlso y
zw = z Or w
if xy AndAlso zw Then
精彩评论