CHAPTER 4
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.