Base Classes and Inheritance

Class inheritance is a commonly used construct1 in object-oriented languages, and C# provides a full implementation.

The Engineer Class

The following class implements an Engineer class and methods to handle billing for that Engineer.

using System;class Engineer{       // constructor    public Engineer(string name, float billingRate)    {       m_name = name;       m_billingRate = billingRate;    }       // figure out the charge based on engineer's rate    public float CalculateCharge(float hours){       return(hours * m_billingRate);    }       // return the name of this type    public string TypeName() ...

Get A Programmer's Guide to C# 5.0, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.