代码:
public A{
如果a=5,throw exceptionA
如果a=9,throw exceptionB
}那么我在调用这个方法的时候,怎么同时捕获这两个异常?try{
  A
}catch(exceptionA)
{
}exceptionB怎么捕获?

解决方案 »

  1.   

    try{
      A
    }catch(exception e)
    {
      if (e is exceptiona)
      {
      }
      else if (e is exceptionb)
      {
      }
    }
      

  2.   

    catch (Exception ex)
    {
    if(ex is exceptionA)
    {
    //捕获A异常
    }
    if(ex is exceptionB)
    {
    //捕获B异常
    }
    }
      

  3.   

    try{
      A
    }catch(exceptionA)
    {
      ...
    }
    catch(exceptionA)
    {
     ...
    }
      

  4.   

    try
       { 
         A
       }
    catch(ExceptionA)
    {
    }
    catch(ExceptionB)
    {
    }
      

  5.   

    上面写错了try{
      A
    }catch(exceptionA)
    {
      ...
    }
    catch(exceptionB)
    {
     ...
    }
      

  6.   

    try{
      A
    }catch(exceptionA)
    {
    }
    catch(exceptionB)
    {
    }
      

  7.   

    try
    {
      A
    }catch(ExcepionA a)
    {
     
    }catch(ExcepionB b)
    {
     
    }