Declare a House object reference named myHouse : Object Reference : Class C# Examples


C# Examples » Class » Object Reference »

 

Declare a House object reference named myHouse









    
public  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;

        System.Console.WriteLine("Creating  a  House  object  and  assigning  its  memory  location  to  myHouse");
        myHouse  =  new  House();

    }

}
    
   
  
   



Output

Creating a House object and assigning its memory location to myHouse


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Object Reference