Short circuiting statement evaluation — is this guaranteed? [C#]

后端 未结 6 2282
不思量自难忘°
不思量自难忘° 2020-12-10 11:53

Quick question here about short-circuiting statements in C#. With an if statement like this:

if (MyObject.MyArray.Count == 0 || MyObject.MyArray[0].SomeValu         


        
6条回答
  •  情话喂你
    2020-12-10 12:43

    Yes, it is guaranteed, but you can still get a null reference exception if MyArray is null (or MyObject for that matter obviously).

提交回复
热议问题