Check out example codes for "exception handling c# stack overflow". It will help you in understanding the concepts better.

Code Example 1

class Program
    static int n;
    static int topOfStack;
    const int stackSize = 1000000; // Default?

    // The func is 76 bytes, but we need space to unwind the exception.
    const int spaceRequired = 18*1024; 

    unsafe static void Main(string[] args)
        int var;
        topOfStack = (int)&var;


    unsafe static void recurse()
        int remaining;
        remaining = stackSize - (topOfStack - (int)&remaining);
        if (remaining < spaceRequired)
            throw new Exception("Cheese");

Learn ReactJs, React Native from