when i do this
static void Main()
{
Main();
}
I receive stackoverflow exception. As i have read so far about C# they say ONLY local variable of value types (and short living ones) will go on stack.
But here in the code there are no local variable to go on stack then what overflows it ?
I know from assembly code line Perspective that reference to Main() will go on stack too ? Is that right ?
Each time you call main(), the return address is saved in the stack, which will eventually cause your stack to blow up
Each function/method call uses stack to store the return location. Here, you have an infinite recursion which eventually stops because stack space gets exhausted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With