How can I check if a getter/setter of a property in a class, has thrown an exception? (Before accessing it)
Example
For example in this picture, the ExitTime
property of a process threw an exception of type System.InvalidOperationException
If I use process.ExitTime
, I get another runtime exception: No process is associated with this object.
Technically it hasn't thrown an exception before you use the accessor method. The only reason that window shows it is because it tried to get the property .
So you can't detect this. All you can do is wrap the accessing code in a try/catch
block to catch the exception when it is thrown.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.