【发布时间】:2014-07-26 07:35:47
【问题描述】:
有没有办法检查对象的成员变量的异常?
例如,我有一个名为 rcp 的 Recipient 对象。 AddressEntry 是该对象的成员。我想在使用 AddressEntry 之前检查成员的异常情况。
我想编写一个方法来检查成员变量,但我没有想法。不要使用 try-catch
private voice GetEmail(Outlook.NameSpace otl, string email){
//...
Recipient rcp = otl.CreateRecipient(email);
if (rcp != null && CheckException(rcp))
{
//do my code
}
//...
}
private bool CheckException(Recipient rcp)
{
//if AddressEntry of rcp object does not threw exception, return true
return false;
}
您能给我一些建议或建议吗?
【问题讨论】:
标签: c# winforms exception outlook