Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Mutilevel Inheritance
WhatsApp
Sandeep Kumar
Dec 21
2015
605
0
1
Multi level Inherita
1. Class Person
2. String PName,PColor,PQualification,PDesignation;
3. Int PAge;
4. Public
void
Get()
5. {
6. Console.WriteLine(
"Enter the person's Name,Color,Qualification,Designation and Age "
);
7. This.Pname=Console.ReadLine();
8. This.PColor=Console.ReadLine();
9. This.PQualification=Console.ReadLine();
10. This.PDesignation=Console.ReadLine();
11. This.PAge=Convert.ToInt32(Console.ReadLine());
12. }
13. Public
void
Display()
14. {
15. Console.WriteLine(
"Person Name is :"
+This.PName);
16. Console.WriteLine(
"Person Color is :"
+This.PColor);
17. Console.WriteLine(
"Person Qualification is :"
+This.PQualification);
18. Console.WriteLine(
"Person Designation is :"
+This.PDesignation);
19. Console.WriteLine(
"Person Age is :"
+This.PAge);
20. }
21. Class Father:Person
22. String FName,FColor;
23. Int FAge;
24. Public
void
Get()
25. {
26. Console.WriteLine(
"Enter the Person’s Father Name,Color and Age "
);
27. This.FName=Console.ReadLine();
28. This.FColor=Console.ReadLine();
29. This.FAge=Convert.ToInt32(Console.ReadLine());
30. }
31. Public
void
Display()
32. {
33. Console.WriteLine(
"Father’s Name is :"
+This.FName);
34. Console.WriteLine(
"Father’s Color is :"
+This.FColor);
35. Console.WriteLine(
"Father’s Age is :"
+This.FAge);
36. }
37. Class Mother:Father
38. String MName,MColor;
39. Int MAge;
40. Public
void
Get()
41. {
42. Console.WriteLine(
"Enter the Person’s Mother Name,Color and Age "
);
43. This.MName=Console.ReadLine();
44. This.MColor=Console.ReadLine();
45. This.MAge=Convert.ToInt32(Console.ReadLine());
46. }
47. Public
void
Display()
48. {
49. Console.WriteLine(
"Mother’s Name is :"
+This.MName);
50. Console.WriteLine(
"Mother’s Color is :"
+This.MColor);
51. Console.WriteLine(
"Mother’s Age is :"
+This.MAge);
52. }
53. Class MultilevelInheritance
54.
public
void
Main()
55. {
56. Mother obj=
new
Mother();
57. obj.Get();
58. obj.Display();
59. }
60. Console.Read();
61. }
Multilevel Inheritance
C#
Up Next
Mutilevel Inheritance