web applications - ASP.NET: Implementing Init and Dispose methods -


can asp.net web application have 1 init , 1 dispose method or can implement these per class want associate such methods?

more have customer component , customerrecord classes , implement init , dispose methods in both of them.

what proper way this?

requirement:

i want have independent init , dispose methods each aforementioned class.

for classes should disposable, exposing public dispose method, idispsable interface must implemented 'disposability' effective out of scope of explicit user disposal. has been covered many times in many places, including here, example:

public class customer : idisposable {     public void dispose()     {         dispose(true);         gc.supressfinalize(this);     }      protected virtual void dispose(bool disposing)     {         if (disposing)         {             //dispose of managed resources         }         //dispose of unmanaged resources     }      ~customer()     {         dispose(false);     } } 

note destructor (the method starting tilde ~) may not necessary, read details answer linked above clarity on situation of what , why - answers question directly.

as init method, referring constructor?

if so, @ destructor in above example; constructor (or initialiser) can defined in same way minus tilde and, generally, plus explicit access modifier (public, private, et cetera), example:

public class customer {     public customer()     {      } } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -