Or versus OrElse

前端 未结 8 1655
感情败类
感情败类 2020-11-27 04:33

What\'s the difference between or and OrElse?

if temp is dbnull.value or temp = 0

produces the error:

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 04:58

    This is the same behaviour as with C#, where everyone uses the Coditional Or (||) and the Conditional And (&&), where you also have the normal Or (|) and normal And (&). So comparing C# to VB.Net is:

    | => Or

    || => OrElse

    & => And

    && => AndAlso

    The condifitonal boolean operators are very usefull preventing nested if constructions. But sometimes the normal boolean operators are needed to ensure hitting both code paths.

提交回复
热议问题