Software Development  Training Program Zeeshan Hanif
DotNet 3.5-101 Lecture 7 Zeeshan Hanif [email_address] [email_address]
Inheritance <ul><li>What is Inheritance </li></ul><ul><li>Inherited Members </li></ul><ul><li>new method </li></ul><ul><li...
Inheritance <ul><li>Inheritance is a powerful mechanism that allows a class to inherit functionality from an existing clas...
is-a Relationship <ul><li>The is-a relationship is one of specialization. </li></ul><ul><li>When we say, Dog is-a mammal, ...
Car Luxury cars Sports Car
Inheritance <ul><li>In object-oriented terminology, sports cars and luxury cars are  derivedclasses  of car class. Similar...
Example <ul><li>public class Car { </li></ul><ul><li>public int wheels; </li></ul><ul><li>public string color; </li></ul><...
Inheritance <ul><li>Each derived class  inherits  all variables from the base class. Sports cars and luxury cars both inhe...
Inheritance <ul><li>A However, derived classes are not limited to the state and behaviors provided to them by their base c...
Inheritance <ul><li>What is Inheritance </li></ul><ul><li>Inherited Members </li></ul><ul><li>new method </li></ul><ul><li...
Upcoming SlideShare
Loading in …5
×

C Sharp Jn (6)

487 views

Published on

Published in: Automotive, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
487
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

C Sharp Jn (6)

  1. 1. Software Development Training Program Zeeshan Hanif
  2. 2. DotNet 3.5-101 Lecture 7 Zeeshan Hanif [email_address] [email_address]
  3. 3. Inheritance <ul><li>What is Inheritance </li></ul><ul><li>Inherited Members </li></ul><ul><li>new method </li></ul><ul><li>virtual and override methods </li></ul><ul><li>Polymorphism </li></ul><ul><li>Abstract classes </li></ul><ul><li>Sealed classes </li></ul><ul><li>Object class </li></ul><ul><li>Boxing and Unboxing </li></ul><ul><li>Interfaces </li></ul>
  4. 4. Inheritance <ul><li>Inheritance is a powerful mechanism that allows a class to inherit functionality from an existing class. </li></ul><ul><li>For example, Cat, Dog, both are kinds of Mammal. </li></ul><ul><li>Car and Bus both are kinds of Vehicle </li></ul>
  5. 5. is-a Relationship <ul><li>The is-a relationship is one of specialization. </li></ul><ul><li>When we say, Dog is-a mammal, means dog is specialized kind of mammal </li></ul><ul><li>Mammal is generalization kind of Dog </li></ul>
  6. 6. Car Luxury cars Sports Car
  7. 7. Inheritance <ul><li>In object-oriented terminology, sports cars and luxury cars are derivedclasses of car class. Similarly, the car class is the baseclass of luxury car and sports car. </li></ul>
  8. 8. Example <ul><li>public class Car { </li></ul><ul><li>public int wheels; </li></ul><ul><li>public string color; </li></ul><ul><li>} </li></ul><ul><li>public class SportsCar : Car { </li></ul><ul><li>public int noOfSeats; </li></ul><ul><li>} </li></ul>
  9. 9. Inheritance <ul><li>Each derived class inherits all variables from the base class. Sports cars and luxury cars both inherits four wheels, gears etc. </li></ul><ul><li>Also, each derived class inherits methods from the base class. Luxury cars and sports cars share some behaviors: braking and changing speed, for example. </li></ul>
  10. 10. Inheritance <ul><li>A However, derived classes are not limited to the state and behaviors provided to them by their base class. </li></ul><ul><li>Derived classes can add more variables and methods. Sports cars have two seats and, some sports cars have an extra set of gears. </li></ul>
  11. 11. Inheritance <ul><li>What is Inheritance </li></ul><ul><li>Inherited Members </li></ul><ul><li>new method </li></ul><ul><li>virtual and override methods </li></ul><ul><li>Polymorphism </li></ul><ul><li>Abstract classes </li></ul><ul><li>Sealed classes </li></ul><ul><li>Object class </li></ul><ul><li>Boxing and Unboxing </li></ul><ul><li>Interfaces </li></ul>

×