Inheritance - VishalBhanderi31/C-Sharp-OOPS GitHub Wiki

Welcome to the C-Sharp-OOPS wiki!

Hello, Here I am introducing some basic amazing features of C# that every developer must know.

  1. Inheritance
  • Superclass/Baseclass/ParentClass
  • Childclass/Derivedclass/SubClass

Two major benefits to use Inheritance,

  • Code re-use
  • Polymorphic behavior

public class PresentationObject
{
// Common shared code
}

public class Text : PresentationObject
{
// Code specific to Text class
}

In C#, We have an "Object" class, which is a parent of all classes. Also it will automatically be inherited with 4 methods.

  1. Equals()
  2. GetHashCode()
  3. GetType()
  4. ToString()