Member Accessibility : Class Access Modifiers : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Class Access Modifiers »

 

Member Accessibility








    
 


using System;

public class MotorVehicle {
    private string make;
    protected string model;

    public MotorVehicle(string make, string model) {
        this.make = make;
        this.model = model;
    }
    public virtual void Start() {
        TurnStarterMotor();
        System.Console.WriteLine("Vehicle started");
    }

    private void TurnStarterMotor() {
        System.Console.WriteLine("Turning starter motor...");
    }
}

public class Product : MotorVehicle {
    public Product(string make, string model) :
        base(make, model) {
        // do nothing
    }
    public override void Start() {
        Console.WriteLine("Starting " + model);
        base.Start();
    }
}
class MainClass {
    public static void Main() {

        Product myProduct = new Product("Toyota", "MR2");
        myProduct.Start();
    }

}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Class Access Modifiers