-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: JaiGanesh_Sagi
Message 4 in Discussion
1.Singleton design pattern is the one using which you can create instance of a
class only once.
Following is the sample code for getting instance of a class.
private static frmName frm = null;
public static frmName GetInstance()
{
if(frm == null)// verifies the frm whether it is null or not
{
// if frm is null then object is created for this form
frm = new frmName();
return frm; // returns frm object to caller
}
// this will be reached if the object frm is not null
return frm; // returns frm object to caller
}
This method can be accessed like this.
frmName obj = frmName.GetInstance();
obj.Show();
2.So only for the first time while creating new instance it is going to execute
code inside page load event of a form, from second time onwards this code won�t
be executed since you are using the same instance. This means that this will
not hit database again and again to fetch data except for the first time.
3.This is more useful in applications, which has wizard-like interface i.e., in
wizards you have to retain the values entered or selected in each form
throughout the wizard until you exit from the wizard. When you have this method
in each form you can get the same instance every time and values can be
retained in each form and also it decreases the database trips as said earlier.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]