需要知道是否有可用的免费工具或如何在运行时检测NullReferenceException?
说,我有一段代码
SomeObject.SomeMethod() // Here SomeObject can throw NullReferenceException
Run Code Online (Sandbox Code Playgroud)
有没有办法在运行前检测到这个?
为什么SomeObject在调用之前检查是否为null?
C#6
SomeObject?.SomeMethod();
Run Code Online (Sandbox Code Playgroud)
在C#6之前
if(SomeObject!=null) SomeObject.SomeMethod();
Run Code Online (Sandbox Code Playgroud)