Console C#.Net Tutorial

Visual Studio.NET IDE

Define C#.NET

C# Comment

C# Variables

C# Data Types

C# Escape Sequence

C# Operators

Format String

Operator Precedence

C# Keywords

Constant Variable

Type Conversion

Flow Control

C# Arrays

C# Character

C# Strings

User-Define Methods

Variable Scope

C# Enumerations

C# Structure

C# Exception Handling

Object Oriented Programming

C# Classes

Constructor & Destructor

C# Inheritance

C# Polymorphism

C# Operator Overloading

C# Method Overriding

C# Interface

Abstract Classes & Methods

Sealed Classes, Methods

C# Properties

C# Indexer

C# Delegates

C# Generics

C# Collection

C# ArrayList

C# Stack

C# Queue

C# HashTable

C# SortedList

Page Stats

Visitor: 381

C#.Net Inheritance

Inheritance is the ability to inherit the properties of one class into another class without redefining it. Inheritance provides the code reusability.
Types of Inheritance:
1. Single Inheritance: A class is inheriting property of another class. (only one superclass)
2. Multilevel Inheritance: A class is inheriting property of another, and that class is inheriting property of third class.(several super classes)
3. Multiple Inheritance: A class is inheriting property of multiple classes. C# does not support multiple inheritance means we cannot inherit more than one class in a class. But, using interfaces we can implement multiple interfaces. (one superclass, many subclasses)
4. Hierarchical Inheritance: It is like a tree structure, a parent class is inheriting by two or more child classes. (subclass derived from another subclass)

Access Modifiers:
Modifiers can indicate the visibility of a method.

Modifiers Meaning
public Class accessible from anywhere
protected The item is visible only to any derived type.
none or internal Accessible within a class only.
private The item is visible only inside the type to which it belongs.

Types of Inheritance

Inheritance Image