Abstract Classes and Methods : Abstract Class : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Abstract Class »

 

Abstract Classes and Methods








    
 


using System;

abstract public class MotorVehicle {
    public string make;
    public string model;

    public MotorVehicle(string make, string model) {
        this.make = make;
        this.model = model;
    }
    abstract public void Accelerate();

}

public class Product : MotorVehicle {
    public Product(string make, string model) :
        base(make, model) {
        // do nothing
    }

    public override void Accelerate() {
        Console.WriteLine("In Product Accelerate() method");
        Console.WriteLine(model + " accelerating");
    }
}


class MainClass {
    public static void Main() {
        Product myProduct = new Product("Toyota", "MR2");
        myProduct.Accelerate();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Abstract Class