我相信 C # 一旦能够告诉结果,就会停止计算 if 语句条件。例如:
if ( (1 < 0) && check_something_else() )
// this will not be called
由于条件 (1 < 0)
的计算结果为 false
,因此不能满足 &&
条件,并且不会调用 check_something_else()
。
C # 如何使用异步函数计算 if 语句? 它是否等待两个函数都返回? 例如:
if( await first_check() && await second_check() )
// ???
这会短路吗?