0% found this document useful (0 votes)
32 views9 pages

Programming C# 2.0, 3.0, 4.0: Muhammed Ali Sakhi Microsoft Certified Trainer

Uploaded by

alisakhi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views9 pages

Programming C# 2.0, 3.0, 4.0: Muhammed Ali Sakhi Microsoft Certified Trainer

Uploaded by

alisakhi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Programming C# 2.0, 3.0, 4.

Muhammed Ali Sakhi


Microsoft Certified Trainer

© PakDev.net
Agenda
Inheritance
Polymorphism
Sealed Classes

© PakDev.net
Inheritance
Ability to reuse, extend, and modify another
classes

You add new code to add the required features

Base class and derived class

Inherit from only one base class

© PakDev.net
Inheritance
The derived class implicitly gains all the
members of the base class, except constructors
and destructors

Private members are not accessible to child


classes

Protected members are accessible only to child


classes

© PakDev.net
Calling base Class Constructors
Constructor declaration must use base keyword

Use the base keyword

Derive class can declare members with same


name as those of base class members

© PakDev.net
Polymorphism
A derive class can override base class methods
Use the virtual keyword in base class
Use the override keyword in the child classes
Virtual methods cannot be static or private
Override methods cannot be static or override
You cannot override a non virtual method
Override methods cannot be explicitly virtual
You can override an override method

© PakDev.net
Using Sealed Classes
You cannot derive from a sealed class

Use the sealed keyword

© PakDev.net
Inheritance

Demo

© PakDev.net
Thank you
PakDev.net

© PakDev.net

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy