Initialize value inside function only once
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/840397/static-variables-in-c">Static variables in C#</a>  </p>
</blockquote>



<p>If you have a large function and in the middle somewhere you have a value that should be declared only the first time its encounter.</p>

<p>In c++ you can use static for this:</p>

<pre><code>void func() {
  ...
  ...
  static double startPosition = 0.0;
  int var = startPositino - value;
  startPosition = var;
  ...
}
</code></pre>

<p>But in c# you cant have static variables inside a function, is there some other way to do this without declaring it outside the function?</p>
