Inheritance
What is inheritance?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Hiren SoniRank #694 · 3.5K reputationPosted Dec 13, 2009, 4:56 PM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 13, 2009, 5:02 PM EST
Suppose you have a class like below
class A
{
string Name;
string Age;
}
now you have coded class A but what if you want to Code a Class that hase Same Functionality as A and Additional functionality too. ???
so will you write the above code again to get same functionality as Class A in class B ..???? of course no !!
in this case inheritance can help you to Import the Functionality of Class A into Class B.. it means it can Extend the Functionality .
Class B:A // Inherit Will Import those two variables in Class B
{
//Just add Extra Members that are not In A
string Age;
string Address;
}
so By Look its Looks that we have added only Two New Variable in Class b but While accesing the Class B We can use 4 Variables that's in class A and Class B too :)
if my answer helps you then check "Do you like this answer" check box :)
Lalit MRank #1,186 · 1.5K reputationPosted Dec 13, 2009, 7:04 PM EST
What is Inheritance?
The process of sub-classing a class to extend its functionality is called Inheritance.
It provides idea of reusability.
What is Order of Constructor execution in Inheritance?
constructors are called in the order from the top to the bottom (parent to child class) in inheritance hierarchy.
What is Order of Destructor execution in Inheritance?
The destructors are called in the reverse order, i.e., from the bottom to the top (child to parent class) in the inheritance hierarchy.
What are Sealed Classes in C#?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class. (A sealed class cannot also be an abstract class)
Does C# supports Multiple Inheritance?
Multiple inheritance of classes is not allowed in C#.
How do I achieve Multiple Inheritance in C#?
In C# you can implements more than one interface, thus multiple inheritance is achieved through interface.
Which is the ultimate base class for all the classes in .Net?
Sytem.Object, The Object class defined in the System namespace is implicitly the ultimate base class of all the classes in C# (and the .NET framework)
Does structure in C# supports inheritance?
Structures (struct) in C# does not support inheritance, it can only implements interfaces.