adspace


What is polymorphism and its types in c#?

Answer Posted / Surendra Singh Chauhan

Polymorphism is a principle that allows objects of different classes to be treated as if they were objects of the same class. In C#, there are two main types of polymorphism: compile-time polymorphism (also known as static polymorphism) and runtime polymorphism (also known as dynamic polymorphism).
1. Compile-Time Polymorphism: It occurs when methods with the same name but different implementations are defined in derived classes that override base class methods. This is achieved using function overriding and operator overloading.
2. Runtime Polymorphism: It occurs when an object of a derived class is treated as if it were an object of its base class, allowing us to call methods specific to the base class. This is achieved using method overloading, method dispatching, and interfaces.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which namespaces are necessary to create a localized application?

1142


What is expression tree in c#?

998


What is an abstract class c#?

969


How do you inherit a class into other class in c#?

993


Why can't we use a static class instead of singleton?

954


How to assign Null value to Var?

1063