Will all methods in a logical expressions be executed?

前端 未结 5 1999
我在风中等你
我在风中等你 2021-01-27 17:35

In C#, given the two methods

 bool Action1(object Data);
bool Action2(object Data);

that are used in an if statement like this:

5条回答
  •  渐次进展
    2021-01-27 18:22

    If Action1() returns true, Action2() will not be evaluated. C# (like C and C++) uses short-circuit evaluation. MSDN Link here verifies it.

提交回复
热议问题