© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
1 reply
steven preadly

Polymorphism

dose the below sentence simply describes the meaning of Polymorphism
 polymorphism is a Opp pillar that treats the objects created from derived class as a  base class  at runtime
 polymorphism is a Opp pillar that treats the objects created from derived class as a  base class  at runtime

as an example in here the reference variable is pointing to the Employee base class while at run time the method is called on the PartTimeEmployee() type correct ?
public class Employee 
{
    public string? firstName = "FN";
    public string? lastName = "LN";

    public virtual void PrintFullName()
    {
        Console.WriteLine(firstName + " " + lastName);
    }
}

public class PartTimeEmployee: Employee 
{
    public override void PrintFullName()
    {
        Console.WriteLine(firstName + " " + lastName + " - PartTime");
    }
}
Employee employee = new PartTimeEmployee();

employee.PrintFullName();
public class Employee 
{
    public string? firstName = "FN";
    public string? lastName = "LN";

    public virtual void PrintFullName()
    {
        Console.WriteLine(firstName + " " + lastName);
    }
}

public class PartTimeEmployee: Employee 
{
    public override void PrintFullName()
    {
        Console.WriteLine(firstName + " " + lastName + " - PartTime");
    }
}
Employee employee = new PartTimeEmployee();

employee.PrintFullName();

and that is polymorphisim we have a base class method in one class(type) that can have many forms in drived class and the type that the method are called from is defined at runtime
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Polymorphism
C#CC# / help
3y ago
❔ Polymorphism
C#CC# / help
4y ago
Inheritance and polymorphism
C#CC# / help
5mo ago
Structure of system with polymorphism
C#CC# / help
2y ago