title: Local variables vs instance variables
body: <p>I've been doing a lot of research on C# optimization for a game that I'm building with XNA, and I still don't quite understand whether local variables are instance variables give better performance when constantly being updated and used.</p>
  
  <p>According to <a href="http://www.dotnetperls.com/optimization" rel="noreferrer">http://www.dotnetperls.com/optimization</a> , you should avoid parameters and local variables, meaning instance variables are the best option in terms of performance.</p>
  
  <p>But a while ago, I read on another StackOverflow post (I can't seem to find where it was) that local variables are stored in a part of memory that is far quicker to access, and that every time an instance variable is set, the previous value has to be erased as a tedious extra step before a new value can be assigned.</p>
  
  <p>I know that design-wise, it might break encapsulation to use instance variables in that kind of situation, but I'm strictly curious about performance. Currently in my game, I pass around local variables to 3 out of 7 methods in a class, but I could easily promote the variables to instance variables and be able to entirely avoid parameter passing and local variables.</p>
  
  <p>So which would be better?</p>