这里有关于C#中的短路语句的快速问题.使用if语句:
if (MyObject.MyArray.Count == 0 || MyObject.MyArray[0].SomeValue == 0) { //.... }
是否保证评估将在"MyArray.Count"部分之后停止,前提是该部分为真?否则我将在第二部分得到一个空例外.
c# conditional-operator short-circuiting logical-operators
c# ×1
conditional-operator ×1
logical-operators ×1
short-circuiting ×1