Hi
What is the syntax to inherit from a class in C#?
Syntax to inherit from a class in C#
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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
VulpesRank #55 · 29.2K reputationPosted Aug 29, 2012, 4:06 AM EDT
class Derived : Parent
{
// code
}
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Aug 29, 2012, 5:16 AM EDT
public class Manager:Employee
{
//Employee fields, properties, methods and events are inherited
//New Manager fields, properties, methods and events go here..
}
When a class declares a base class it inherits all the members of the class except constructors.
VulpesRank #55 · 29.2K reputationPosted Aug 29, 2012, 5:25 AM EDT
Notice also that in C# a class can only inherit from one other class. If you don't specify a parent class, then it implicitly inherits from System.Object which sits at the top of the inheritance hierarchy.
If you mark a class as 'sealed', then it cannot be inherited from.