In general is it better (for performance) to use stack variables or temporary member variables?
I have a function that is being called in “real time” and there are a number temporary variables (of various data types) that are required. Is it better to just use stack variables (i.e. in function) or to use private member variables in the class?
If they are only needed inside the method, keep them in the method as local method variables. This isn’t primarily a speed concern (although a “ldloc” is presumably less effort than a “ldarg0, ldfld” combination) – but rather: scope: it reduces the size of the object, and also allows for re-entrancy without confusion.
Note also: not all local method variables go on the stack ;p