110,536
社区成员
发帖
与我相关
我的任务
分享
private bool B()
{
...
if(e=f)
return true;
return false;
}
void A()
{
if(B)
return;
...
}
可以用下面的方式来做,层层上抛,层层抓取,细化异常 空Catch 可以做到 return
class AException :Exception{}
class BException :Exception{}
class CException :Exception{}
void Main()
{
try
{
A();
B();
C();
}
catch(AException aex)
{}
catch(BException bex)
{}
catch(BException cex)
{}
}
void A()
{
try
{}
catch(Exception ex)
{
throw new AException(ex);
}
}
void B()
{
try
{}
catch(Exception ex)
{
throw new BException(ex);
}
}
void C()
{
try
{}
catch(Exception ex)
{
throw new CException(ex);
}
}