A clear, layman's explanation of the difference between | and || in c#?

后端 未结 11 532
余生分开走
余生分开走 2020-12-02 12:51

Ok, so I\'ve read about this a number of times, but I\'m yet to hear a clear, easy to understand (and memorable) way to learn the difference between:

if (x |         


        
11条回答
  •  -上瘾入骨i
    2020-12-02 13:38

    Good answers, but let me add that the right-side expressions for || is not evaluated if the left-side expression is true. Keep this in mind for cases where the evaluation terms are a) performance-intensive or b) produce side effects (rare).

提交回复
热议问题