how to rewrite a recursive method by using a stack?
<p>Since C# doesn't support the optimization of recursive call very well (e.g tail recursion). It seems I have to switch my code style from functional programming to something I am not familiar with.</p>

<p>I know sometimes iterative method alternative exists to a recursion method, but usually it is quite hard to find an efficient one.</p>

<p>Now, in generally, I believe all recursive methods can be rewritten by using <code>stack&lt;T&gt;</code> data structure somehow.</p>

<p>Where can I find the tutorial or introduction or general rule to this?</p>

<p>e.g., what if I wanna rewrite  greatest common divisor method? given m>n</p>

<pre><code>    int gcd(int m, int n)
     {
          if (n==0)
             return m;
          else
              return gcd(n,m%n);
      }
</code></pre>

<p><strong>Update</strong></p>

<p>Probably it is a bad example as it indeed is tail recursive.  Plz just ignore the fact and consider it is a normal recursive method.</p>
