Get your own Java server
Vehicle.cs
Car.cs
Program.cs
 
Vehicle.cs
using System;

namespace MyApplication
{
  class Vehicle  // Base class
  {
    public string brand = "Ford";  // Vehicle field
    public void honk()             // Vehicle method 
    {
      Console.WriteLine("Tuut, tuut!");
    }
  }
}

                  
Car.cs
using System;

namespace MyApplication
{
  class Car : Vehicle  // Derived class
  {
    public string modelName = "Mustang";  // Car field
  }
}

                  
Program.cs
using System;

namespace MyApplication
{
  class Program
  { 
    static void Main(string[] args)
    {
      // Create a myCar object
      Car myCar = new Car();

      // Call the honk() method (From the Vehicle class) on the myCar object
      myCar.honk();

      // Display the value of the brand field (from the Vehicle class) and the value of the modelName from the Car class
      Console.WriteLine(myCar.brand + " " + myCar.modelName);
    }
  }
}

                  
Tuut, tuut!
Ford Mustang