I have a 20 by 10 array consisting of doubles and short strings (fewer than 15 chars each). This array is used only inside a function when it is called. The strings are constant only the doubles vary.
Should I leave this array local to the function? Any consideration that I am not aware of?
I am in the process of planning this function and array. The array might have additional types, most likely some enum types, so I don’t have any concrete code to show yet. All I know is the approximate size and dimension of the array.
You simply cannot have a local instance of an array.
Arrays are reference types so the actual memory is always allocated on the heap.
So: Yes, do keep your (reference-to-an) array variable local if that fits its usage. And it does: