Why does stack get truncated in Exception.StackTrace?

前端 未结 4 1196
梦如初夏
梦如初夏 2021-02-05 18:31

Why does the high part of the stack (in Exception.StackTrace) gets truncated? Let\'s see a simple example:

public void ExternalMethod()
{
  InternalMethod();
}         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 19:03

    I know that in a catch block if you do throw ex; it truncates the stack trace at that point. It's possible that it's "by design" for throw since just throw; doesn't truncate the stack in a catch. Same may be going on here since you're throwing a new exception.

    What happens if you cause an actual exception (i.e. int i = 100/0;)? Is the stack trace still truncated?

提交回复
热议问题