title: I'm making a Console Application Game (C#), and I'm running into Stack Overflow Error. How to avoid?
body: <p>My game has multiple methods for each state of the game and these methods call each other where applicable. This is causing a Stack Overflow Error after a while. Is there any way to avoid this, perhaps a workaround?</p>
  
  <p>Edit: As the user below suggested my code is basically:</p>
  
  <pre><code>void a()
  {
      b();
  }
  
  void b()
  {
      a();
  }
  </code></pre>
  
  <p>In this code I intended to use recursion in order to change game states.
  Is there any way to reset the stack so it doesn't cause an overflow error and then return to the methods.</p>
  
  <p>Possible Fix: (Did this just delay the Stack Overflow or has it gotten rid of it?)</p>
  
  <pre><code>int tracker;
  void start()
  {
      a();
      resetter();
  }
  
  void a()
  {
      b();
  }
  
  void b()
  {
      if (tracker &gt; 10)
      {
          tracker = 0;
          return;
      }
      else
          tracker++;
      a();
  }
  
  void resetter()
  {
      start();
  }
  </code></pre>