Retain local variable across method calls
<p>Is there a way in C# to have a method retain a variable across different calls? For example:</p>

<pre><code>private void foo()
{
    int j; //declare this so as it isn't destroyed with the stack frame.
    int i = calculateSomeValue() + j;
    j = i;
}
</code></pre>

<p>The normal way I would do this would be with a member variable like this:</p>

<pre><code>private int j = 0;
private void foo()
{
    int i = calculateSomeValue() + j;
    j = i;
}
</code></pre>

<p>I don't like how the variable <code>j</code> can be accessed in all of the other methods of the class. Plus it just <em>seems</em> messy this way: defining a member variable when it will only be used in one method to keep track of the value of <code>i</code> when the method was last called.</p>

<p>Is this possible in a nice/clean way? Or should I just use the member variable way and forget about it?</p>