c#如何在函数返回时同时抛出异常
aqjy 2008-12-14 08:01:06 例有如下函数:
public int DeleteFile(string fileName)
{
try
{
File.Delete(fileName);
return 0;
}
catch (Exception ee)
{
throw ee;
return 1;
}
}
编译提示 return 1无效(若先 return 1; 再 throw ee,编译提示 throw ee无效)而我希望在发生异常时,既能返回数值1,又能在调用该函数的父函数中处理异常,该怎么做?