static void Main(string[] args)
Vehicle v = new Vehicle();
Console.WriteLine(v.DisplayInfo());
Console.WriteLine(c.DisplayInfo());
Console.WriteLine(v.DisplayInfo());
Console.WriteLine(c.DisplayInfo());
public string Make { get { return this.make; } set { this.make = value; } }
public string Model { get { return this.model; } set { this.model = value; } }
public int Year { get { return this.year; } set { this.year = value; } }
this.model = "BMW X3 Series";
public Vehicle(string make, string model, int year)
public virtual string DisplayInfo()
return "the make is " + this.make + ", the model is " + this.model + ", and the year is " + this.year;
internal class Car : Vehicle
private int numberOfDoors;
private bool isConvertible;
public int NumberOfDoors { get { return this.numberOfDoors; } set { this.numberOfDoors = value; } }
public bool IsConvertible { get { return this.isConvertible; } set { this.isConvertible = value; } }
this.isConvertible = false;
public Car(int numberOfDoors, bool isConvertible, string make, string model, int year) : base(make, model, year)
this.numberOfDoors = numberOfDoors;
this.isConvertible = isConvertible;
public override string DisplayInfo()
return base.DisplayInfo() + " and it has " + this.numberOfDoors + " doors and is " + (this.isConvertible? "a convertible":"not a convertible");