.net - Why there is no static destructor? -


i try avoid using static classes in production code cant injected, there no control on default initialization , lastly can't clean resources implicitly there no destructor static objects. additionaly, cannot implement idisposable static class well, sounds static classes never being wrapper around unmanaged resources... totally seems singletons better solution replace use of static classes directly in case. question - why doesn't compiler support static destruction, after difference make gc keep track of references static object vs instance?

there's no such thing "static object". static variables in types loaded in app domain treated gc roots until app domain unloaded.

if want things when app domain unloaded, subscribe appdomain.domainunload , appdomain.processexit.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -