Inheritance

noun

say it: “in-HAIR-ih-tuns” /ɪnˈhɛrɪtəns/

Making a new class from an existing one, so it gets the existing class's members and adds its own.

What is Inheritance in C#?

Inheritance — Creating a class that receives accessible members from another class.

class Alert
{
    public virtual string Text()
    {
        return "Alert";
    }
}

class EmailAlert : Alert
{
    public override string Text()
    {
        return "Email";
    }
}

In a sentence

  • “Through inheritance, Ebook gets Title and Price from Book.”

Level: Journeyman · More C# terms at this level

Updated

In other subjects