This is my class assignment.
class Designation
{
private string strDesigNo;
private string strDesigName;
private string strDesigDesc;
public string DesigNo
{
set { strDesigNo = value; }
get { return strDesigNo; }
}
public string DesigName
{
set { strDesigName = value; }
get { return strDesigName; }
}
public string DesigDesc
{
set { strDesigDesc = value; }
get { return strDesigDesc; }
}
}
In my user interface form, when I click the Save button, I assign values to my department class and then submit it to save the method in another class as follows.
private void btnSave_Click(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(txtDesignationNumber.Text.Trim().ToString()))
{
if (!string.IsNullOrEmpty(txtDesignationName.Text.Trim().ToString()))
{
if(!string.IsNullOrEmpty(txtDesignationtDescription.Text.Trim().ToString()))
{
objDesignation.DesigNo = txtDesignationNumber.Text.Trim().ToString();
objDesignation.DesigName = txtDesignationName.Text.Trim().ToString();
objDesignation.DesigDesc=txtDesignationtDescription.Text.Trim().ToString();
objDesignationBLL.insertDesignation(objDesignation);
}
}
}
}
// I need immediately after sending the values of objects to the insertDesignation method, clear all values.
// This means that I need it as follows.
objDesignation.DesigNo ='';
objDesignation.DesigName = '';
objDesignation.DesigDesc = '';
Is there a good practice for these values of an object variable to be deleted to zero without deleting the object or setting the object to null?
source
share