Display the field values using object reference
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;
System.Console.WriteLine("myHouse details:");
System.Console.WriteLine("myHouse.make = " + myHouse.make);
System.Console.WriteLine("myHouse.model = " + myHouse.model);
System.Console.WriteLine("myHouse.color = " + myHouse.color);
System.Console.WriteLine("myHouse.yearBuilt = " + myHouse.yearBuilt);
}
}
Output myHouse details:
myHouse.make = ABC
myHouse.model = Apartment
myHouse.color = black
myHouse.yearBuilt = 1995
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|