函数中抛出异常让调用该函数的函数捕获,要怎样做? 函数中抛出异常让调用该函数的函数捕获,要怎样做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void Method1(){ try { Method2(); } catch(Exception ex) { //todo .... }}private void Method2(){ //to do... 这里可以捕捉,然后throw出来,或者不处理~~~~~} 恩。不错。那么函数后面的throw Exception是什么意思,格式是怎样的? 直接用参数Out string errMsgcatch(Exception ex){ errMsg=ex.Message;} catch (Exception ex) { errMsg = ex.Message; return null; }errMsg 为输出参数,在调用出判断errMsg是否为string.Empty string strError = "";private void Method1() { try { Method2(); } catch(Exception ex) { //throw ex; 拋出異常strError = es.Message;//把異常信息付給 strError } } private void Method2() { try { //to do... } catch(Exception ex) { //todo .... 在这里可以处理一些额外的事情 throw ex;//这里thorw出去,可以在Method1中接收~~~~ }} strError = es.Message;//把異常信息付給 strError throw exception方法呢? DbDataadapter更新不了数据库的问题 【初学者求教】CheckedListBox如何全选全消? 放大和缩小bmp图片怎样不失真? 工作区内有滚动条,如何在鼠标移动到工作区上的被隐藏的部分时,滚动条可以自动移动,从而展开被隐藏的的部分? 请教一个xpath表达式的问题,如何匹配特殊字符如“,‘ 求助vs Installer:错误代码 2869 安装问题解决方案 [STAThread]和[DllImport...]的疑问 在线等待 自增主键的弊端 串口调试,发送接收数据问题 巨简单的问题! 能不能锁定注册表? C# pictureBox 里面的 image 如何更新?
{
try
{
Method2();
}
catch(Exception ex)
{
//todo ....
}
}private void Method2()
{
//to do... 这里可以捕捉,然后throw出来,或者不处理~~~~~
}
catch(Exception ex)
{
errMsg=ex.Message;
}
{
errMsg = ex.Message;
return null;
}
errMsg 为输出参数,在调用出判断errMsg是否为string.Empty
private void Method1()
{
try
{
Method2();
}
catch(Exception ex)
{
//throw ex; 拋出異常
strError = es.Message;//把異常信息付給 strError
}
}
{
try
{
//to do...
}
catch(Exception ex)
{
//todo .... 在这里可以处理一些额外的事情
throw ex;//这里thorw出去,可以在Method1中接收~~~~
}
}
throw exception方法呢?