i wonder how much calls we can perform in stack in c# before we get stack overflow exception
so i decided to write the following code
static void Method2(int Calls)
{
if(!Calls.Equals(0))
Method1(--Calls);//if more calls remain call method1 and reduce counter
}
static void Method1(int Calls)
{
if (!Calls.Equals(0))//if more calls remain call method2 and reduce counter
Method2(--Calls);
}
static void Main(string[] args)
{
var Calls= 42994;//number of calls(stack overflow appears for large number)
Method1(Calls);
}
my question is how compiler decides to throw stack overflow exception is this about memory limitations? once i put 42995 i got stackoverflow but this number is not constant so how this works?