O'Reilly logo

A Programmer's Guide to C# 5.0, 4th Edition by Nick Wienholt, Eric Gunnerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 4

image

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required