stackoverflow object code example

Example: objects referencing objects stack overflow

/* If you make a static object and a non-static object of the same class,
and then use that static object in any way, you will get a stack overflow.

I will give an example of some code that will result in stack overflow.
*/

using System;
using System.Collections.Generic;

namespace Grepper
{
    class Program
    {
        static Program obj_1 = new Program(); //static of Program class
        Program obj_2 = new Program(); //non-static of Program class

        static void Main(string[] args)
        {
            obj_1.DoSomething(); //using static object
        }

        void DoSomething()
        {
        }
    }
}