What happens if both catch and finally blocks throw exception?

前端 未结 5 603
谎友^
谎友^ 2020-12-13 18:26

What happens if both catch and finally blocks throw exception?

5条回答
  •  一整个雨季
    2020-12-13 18:46

    HI Nwaman i think you answer is wrong i have tested it in windows appliaction, i found if u write a program like the below one

    try
    {
        string s = "hu";
        int i = int.Parse(s);
    }
    catch (Exception ex)
    {
        string s = "hu";
        int i = int.Parse(s);
        throw new Exception();
    }
    finally
    {
        MessageBox.Show("hi");
    }
    

    and this will not result finally to excute,

提交回复
热议问题