问题描述
我很好奇是否有人知道And / AndAlso和
Or / OrElse的组合在性能方面的比较。
这需要更多的系统工作对And
进行两次评估或对AndAlso进行短路?
纯粹是为了启蒙。
提前谢谢。
- Arthur Dent。
我更喜欢''AndAlso''/''OrElse''应该进行逻辑操作。
在许多情况下短路更快,因为通常不需要评估部分
表达式。
-
Herfried K. Wagner [MVP]
< URL:http://dotnet.mvps.org/>
I was just curious if anyone knows how the combinations of And/AndAlso and
Or/OrElse compare in terms of performance.
Which takes more work for the system, performing two evaluations on an And
or performing short-circuiting on an AndAlso?
Purely for enlightenment.
Thanks in advance.
- Arthur Dent.
I would prefer ''AndAlso''/''OrElse'' when a logical operation should be done.
Short circuiting is faster in many cases, because often parts of the
expression don''t need to be evaluated.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
这篇关于而且还有AndAlso,表现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!