Without using recursion how can a stack overflow exception be thrown?

前端 未结 10 2094
自闭症患者
自闭症患者 2021-01-18 04:19

Without using recursion how can a stack overflow exception be thrown?

10条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-18 05:03

    You can allocate a few bytes in the stack as well.

    static void Main(string[] args)
    {
        Span b = stackalloc byte[1024 * 1024 * 1024]; // Process is terminating due to StackOverflowException.
    }
    

提交回复
热议问题