Book Image

Learn C# in 7 days

By : Gaurav Aroraa
1 (1)
Book Image

Learn C# in 7 days

1 (1)
By: Gaurav Aroraa

Overview of this book

This book takes a unique approach to teach C# to absolute beginners. You’ll learn the basics of the language in seven days. It takes a practical approach to explain the important concepts that build the foundation of the C# programming language. The book begins by teaching you the basic fundamentals using real-world practical examples and gets you acquainted with C# programming. We cover some important features and nuances of the language in a hands-on way, helping you grasp the concepts in a fluid manner. Later, you’ll explore the concepts of Object-Oriented Programming (OOP) through a real-world example. Then we dive into advanced-level concepts such as generics and collections, and you’ll get acquainted with objects and LINQ. Towards the end, you’ll build an application that covers all the concepts explained in the book. By the end of this book, you will have next-level skills and a good knowledge of the fundamentals of C#.
Table of Contents (15 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Inheritance


Inheritance is one of the most important features/concepts of OOP. It is self-explanatory in name; inheritance inherits features from a class. In simple words, inheritance is an activity performed at compile-time as instructed with the help of the syntax. The class that inherits another class is known as the child or derived class, and the class which is being inherited is known as the base or parent class. Here, derived classes inherit all the features of base classes either to implement or to override.

In the coming sections, we will discuss inheritance in detail with code examples using C#.

Understanding inheritance

Inheritance as a feature of OOP helps you to define a child class. This child class inherits the behavior of the parent or base class.

Note

Inheriting a class means reusing the class. In C#, inheritance is symbolically defined using the colon (:) sign.

The modifier (refer to Chapter 2, Day 02 - Getting Started with C#) tells us what the scope of the reuse of the base...