“扔”和“扔前”有什么区别吗?

“扔”和“扔前”有什么区别吗?

有些帖子问这两者之间有什么区别。
(我为什么要提这个.)

但是我的问题在另一个错误中是不同的,我称之为“抛出前”。上帝般的处理方法

public class Program {
    public static void Main(string[] args) {
        try {
            // something
        } catch (Exception ex) {
            HandleException(ex);
        }
    }

    private static void HandleException(Exception ex) {
        if (ex is ThreadAbortException) {
            // ignore then,
            return;
        }
        if (ex is ArgumentOutOfRangeException) { 
            // Log then,
            throw ex;
        }
        if (ex is InvalidOperationException) {
            // Show message then,
            throw ex;
        }
        // and so on.
    }}

如果try & catchMain,那我就用throw;重新抛出错误。但是在上面简化的代码中,所有的异常都会通过HandleException

是吗?throw ex;具有与调用相同的效果。throw当被召唤入内HandleException?


白衣染霜花
浏览 743回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP