title: Emulating function static variables using threadstatic static fields?
body: <p>For some static methods I realise it is extremely convenient to use a small array to temporarily store values during an operation. Said array is useful because you need indexing, but allocating that small array everytime the method is invoked.</p>
  
  <p>Is <em>this</em> a good way to work around the lack of C-like static locals in C#?</p>
  
  <pre><code>[ThreadStatic]private static int[] staticregister = new int[4];
  
  public static bool CoolStaticMethod(int[] largearray)
  {
      //...
  }
  </code></pre>
  
  <p>My assumption is that a method which can't call itself, either directly (recursive) or indirectly, can only be called singularly in a single thread, thus the fake static local should be declared thread-static and the problem is largerly solved.</p>
  
  <p>Edit:</p>
  
  <p>I must add that the contents of the register is garbage between method invocations.</p>