通过以下方式检查null是否有任何区别:
object x;
// more code to work on x
if (null == x)
return;
Run Code Online (Sandbox Code Playgroud)
和
object x;
// more code to work on x
if (x == null)
return;
Run Code Online (Sandbox Code Playgroud)
我认为它只是一种风格偏好,并且没有任何错误(代码逻辑或性能),但想要检查.我认为后者更容易阅读,但我的同事坚持以第一种方式编写它.它让我疯了.谢谢.