Ken H

Ken H

  • NA
  • 646
  • 354.8k

Releases the managed resources in c#

Mar 7 2015 9:36 AM
Hello friend,
      How to determine whether the object is recovered?
 
 class Program{
static void Main(string[] args){

Student student = null;

using (student = new Student())
{
Console.WriteLine("student is null:{0}\n",student == null);

}

Console.WriteLine("student is null:{0}\n",student == null);
}
}

public class Student : IDisposable
{

public Student() { }

~Student()
{
Console.WriteLine("Start Execute Destructor...\n");
}

public void Dispose(){

Console.WriteLine("Start Execute Dispose...\n");

}

}
 
Thanks.
 

Answers (4)