C#: Limit global field's scope to method / property OR preserve method's / property's local variable's value between calls -


  float last time = 0.0 f; Zero Draw (Float Current Time) {If (Current Time - Final Time> 0.5f) {// Enough FPS} Last Time = Current Time; }  

And it makes me crazy that the global "state" area (here is the "last time") is appearing in the whole class, while it is only necessary in one method. Is there any way to limit the visibility area of ​​this global area or to make it local, but to keep the value between calls? The same question applies to the areas used by properties (which can be automated and can not be automated)

Thanks in advance for any suggestions ...

< P>

The only way it will be private in just one part of the class is that it will be able to create a different object that manages this property.

However, I would recommend to reconsider it a bit. The idea of ​​personalizing a personal member to keep it in the classroom itself - If you are worried about your class, considering your own data, it is time to rebuild in small classes, each of its own work with.

This "smell" of a class is getting very big.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -