Skip to Content
Beginning C# 3.0
book

Beginning C# 3.0

by Jack Purdum
May 2008
Beginner
550 pages
13h 22m
English
Wrox
Content preview from Beginning C# 3.0

15.1. What is Inheritance?

Up until now, inheritance has been a concept sitting in the background, making your life easier every time you designed a user interface for your programs. Indeed, you have probably glossed over the fact that the program line

public class frmMain : Form

enabled you to inherit all of the basic functionality of a Windows form without having to write that code yourself. In fact, the colon in the preceding statement could be verbalized as "inherits from." The concept of inheritance is built upon the notion that many objects share similar properties. In the preceding statement, you are stating that you wish to create a new class named frmMain that inherits all of the functionality of a basic Windows form. Being able to inherit this functionality means that you don't have to write, test, debug, and maintain that inherited code yourself. Therefore, the driving force behind inheritance is to simplify writing code. Inheritance makes it possible for your code to extend one class to suit your specific needs. Simply stated, inheritance is the ability to take one class and extend that class to suit a similar, albeit different, purpose. An example will help explain inheritance.

15.1.1. An Inheritance Example

Some time ago I was contracted to write a program for a real estate investor. The type of real estate the investor purchased could be classified as apartments, commercial properties (such as small strip malls), and residential homes. I sat down with her and asked ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo, John Arkontaky, Yat Siu
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Capitalism at Risk

Capitalism at Risk

Joseph L. Bower, Herman B. Leonard, Lynn S. Paine

Publisher Resources

ISBN: 9780470261293Purchase book