【发布时间】:2013-07-17 04:20:22
【问题描述】:
有没有更好的方法来处理异常?我可以做同样的事情,但只用一次 try catch 吗?
我需要创建自己的异常类吗?
try
{
firstname = bd["firstname"].ToString();
}
catch (KeyNotFoundException fe)
{
firstname = null;
}
try
{
lastname = bd["lastname"].ToString();
}
catch (KeyNotFoundException fe)
{
lastname = null;
}
try
{
phone = bd["phone"].ToString();
}
catch (KeyNotFoundException fe)
{
phone = null;
}
...
...
【问题讨论】:
-
这是一个 BsonDocument 变量
标签: c# asp.net .net exception try-catch