wyrd
Senior Contributor
(Using C#)
Okay.. static constructors are guaranteed to run sometime before the class is instantiated or called (ie; static method) for the first time, right? Also.. can you make a static destructor? ie; The destructor is guaranteed to run sometime after all instantiated classes are run through the GC (or when the program closes).
I was thinking of encapsulating an imagine inside a class, but every time I create the class I don't want the same image to be loaded over and over again (waste of memory). In short I was thinking of static members to handle this, so I only had a single image loaded that all classes shared.
Is this a good idea? It seems rather logical to me, however if static destructors aren't possible or static works in a different way other then what I described above (according to my understanding of it), I'll have to think of another way to handle this.
Okay.. static constructors are guaranteed to run sometime before the class is instantiated or called (ie; static method) for the first time, right? Also.. can you make a static destructor? ie; The destructor is guaranteed to run sometime after all instantiated classes are run through the GC (or when the program closes).
I was thinking of encapsulating an imagine inside a class, but every time I create the class I don't want the same image to be loaded over and over again (waste of memory). In short I was thinking of static members to handle this, so I only had a single image loaded that all classes shared.
Is this a good idea? It seems rather logical to me, however if static destructors aren't possible or static works in a different way other then what I described above (according to my understanding of it), I'll have to think of another way to handle this.