Articles → .NET → Using keyword for custom class in c#

Using keyword for custom class in c#







Public class Employee {
  public Employee() {
    MyDataSet = new DataSet();
  }
  public DataSet MyDataSet {
    get;
    set;
  }
}




using(Employee emp = new Employee()) {

}






public class Employee: IDisposable {
  public Employee() {
    MyDataSet = new DataSet();
  }
  public DataSet MyDataSet {
    get;
    set;
  }
  public void Dispose() {
    Dispose(true);
    GC.SuppressFinalize(this);
  }

  private bool IsDisposed = false;

  protected virtual void Dispose(bool disposing) {
    if (!IsDisposed && disposing) {
      MyDataSet.Dispose();
      IsDisposed = true;
    }
  }
}





Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 29, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250