• Inheritance is main concept of OOP it show the parent child relationship between classes
• Inheritance is process in which one class get the properties and method from another class
• It's technic of deriving new class from old class.
Types of Inheritance:
1). Single Inheritance
2). Multilevel Inheritance
3). Multiple Inheritance
4). Hybrid Inheritance
5). Hierarchical Inheritance
1). Single Inheritance
In single inheritance class B derived from class A
2). Multilevel Inheritance
In multilevel inheritance class B is derived from class A and class c is derived from class B
3). Multiple Inheritance
In multiple inheritance class C is derived from two class A and class B.
This type of inheritance is not supported in c#.net
4). Hierarchical Inheritance
In Hierarchical Inheritance Class B, class C and class D is derived from Class A.
In Hierarchical Inheritance Class B, class C and class D is derived from Class A.
5). Hybrid Inheritance
Example :
class A
{
void methodA()
{
Console.Write("This is Method A");
}
}
// here class B is derived from class A so it calls single inheritance.....
class B:A
{
void methodB()
{
Console.Write("This is Method B");
}
}
// here class C is derived from class B and class B is derived from class A so it call multilevel
class C:B
{
void methodC()
{
Console.Write("This is Method C");
}
}
// here class D,E and B call derived from A so it call hierarchical inheritance
class D:A
{
void methodD()
{
Console.Write("This is Method D");
}
}
class E: A
{
void methoda()
{
Console.Write("This is Method A");
}
}
See Also :
- How to Get operating system name using C#.net,How ...
- How to Get processor name using C#.net,How to get information about processor using C#.net
- How to upaload image with resize it, How to resize uploaded image and save
- How to get computer name using c#.net
- How to upload and save image in asp.net ?
--
/\/ir@\/ <(.'.)>
0 comments:
Post a Comment
Thanks for comment