Assign values to the House object's fields using object renerence : Object Reference : Class C# Examples


C# Examples » Class » Object Reference »

 

Assign values to the House object's fields using object renerence









    
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.make  =  "ABC";
        myHouse.model  =  "Apartment";
        myHouse.color  =  "black";
        myHouse.yearBuilt  =  1995;

    }

}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Object Reference