Assign null to myHouse (myHouse will no longer reference an object) : null « Class « C# / CSharp Tutorial






class House
{
  public string make;
  public string model;
  public string color;
  public int yearBuilt;

  public void Start()
  {
    System.Console.WriteLine(model + " started");
  }

  public void Stop()
  {
    System.Console.WriteLine(model + " stopped");
  }

}

class MainClass
{
  public static void Main()
  {
    House myHouse;
    myHouse = new House();
    myHouse = null;
  }
}








7.12.null
7.12.1.Assign null to myHouse (myHouse will no longer reference an object)